Dynamic CSS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dynamic CSS

    I am updating a CMS and I needed to use different CSS styles for different pages and times. But having much CSS's like page1.css, page2.css, midnight.css is not enough for me. So, here is a simple trick I did:

    In the html page:
    PHP Code:
    <link rel="stylesheet" type="text/css" href="style.css.php" /> 
    Then in the stylesheet (style.css.php):
    PHP Code:
    <?php
    header
    ("content-type: text/css");
    ?>

    then here goes the CSS code.
    You maybe will need it for causes like, when you want to change the background depending on whats stored in cookies:

    PHP Code:
    body {
    background-color: <?php echo $_COOKIE["bg"]; ?>;
    }
    Goodnight!
    mysterio.al - programming is a functional art

    #2
    You can simply do this.

    <?=$_COOKIE['bg']?>

    Instead of the whole echo string. Learnt that from another persons dynamic css.

    Would appreciate if someone explained it.

    Why that works.
    Perfection comes at a cost



    I accept liberty!

    Comment


      #3
      Ok boy, thats on your choise, I just wanted to write it simple for simple users, because advanced users know that code without needing me to tell it to them. And what you mean with your message? Why that (what?) works?
      mysterio.al - programming is a functional art

      Comment


        #4
        Originally posted by frostymarvelous View Post
        You can simply do this.

        <?=$_COOKIE['bg']?>

        Instead of the whole echo string. Learnt that from another persons dynamic css.

        Would appreciate if someone explained it.

        Why that works.
        the equal symbol is a shortcut syntax for echo and only works with short_open_tag enabled .... using this can save valuable load time

        Comment


          #5
          Ah. Ok. Thanks.
          Its been a timesaver since I found it.
          Perfection comes at a cost



          I accept liberty!

          Comment

          Working...
          X