Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Creating Custom Stylesheets on the fly

    I am working on a project in which users will be able to sign up for a program, lets compare it to a myspace page... and they can customize the look and feel of that page to a very limited extent.

    What is the best way to have them choose colors of the page through CSS, have those changes be there always applied to their page and their page alone?

    I don't need help with the implementation, I currently have it to where users can choose from pre-built stylesheets and those are used, but how do you set it up to where what options they choose in the setup wizard are then creating a new stylesheet just for that user on the fly?

    Thanks a ton,

    SS

  • #2
    New Coder
    Join Date
    Apr 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm sorry, is my question confusing or does nobody really have much of a solution? There must be a way to do it, however the sites like myspace and such would do it to keep that 'custom' look for each user's page... is that a separate css sheet for each user?

    I know the other method would be to dynamically do the CSS inline, which would be pretty easy then just reference the database of what the user chose as their colors etc., but I'm wanting to keep all the CSS in external sheets... is that just not possible?

    SS

  • #3
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    In theory you could have a form field which the user inputs their CSS which is saved server-side into a database, give each user a unique ID and call a stylesheet which pulls up the CSS from the database. What's wrong with this?

  • #4
    New Coder
    Join Date
    Apr 2008
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I get the saving it server-side in a database, we're already doing that with all kinds of other info... and the user has a unique ID already, I don't understand clearly how to 'call a stylesheet which pulls up the CSS from the database' ?

    I know how to do the CSS inline with code pulling the data from the database, but I don't know how to do it in an external stylesheet, is that doable?

  • #5
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    When you initially put the CSS into the database, one of your columns would be the unique ID of the user and the other the CSS.

    You'd call it like this
    Code:
    <link rel="stylesheet" type="text/css" href="/styles/user.php?userid=12345"/>
    Or something similar.

    You would then output a text/css header like this:
    PHP Code:
    <?php
      header
    ('Content-Type: text/css');
    ?>
    Then you would ask the database for the CSS which you put in there earlier by selecting it using the user ID.

    The concept make sense?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •