SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    change stylesheet using php

    hai ,

    i need help to deal with stylesheet.
    is it possible to pass the stylesheet as an orgument to the document using php.

    and how can i use the dynamic style sheet instead of using the existing stylesheet without deleting that.

    it is very urgent.

    thks in advance.

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    somepage.php?css=darkblue

    Then wherever you link in the stylesheet just do something like:
    PHP Code:
    $stylesheet = isset($_GET['css']) ? $_GET['css'] : 'default';
    $stylesheet file_exists('/css/'.$stylesheet.'.css') ? $stylesheet 'default';
    echo 
    '<link href="/css/'.$stylesheet.'.css" rel="stylesheet" type="text/css" />'

  3. #3
    SitePoint Enthusiast sim3's Avatar
    Join Date
    Dec 2005
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this what you are getting at?

    PHP Code:
    <?php
    $style 
    "mycss.css";
    ?>

    <html> 
        <head> 
          <title>My Page</title> 
          <link rel="stylesheet" type="text/css" href="<?=$style ?>" />
        </head> 
         <? 
    ?>
    This is a very simple example. Taking it to another place, I have a Template class which I use to dynamically set things like title, css and javascript. Then later in the script a custom "$template->print_header();" is used to actually send the document head to the browser in a way similar to the example posted above.

  4. #4
    SitePoint Enthusiast sim3's Avatar
    Join Date
    Dec 2005
    Posts
    54
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Re-reading the OP, I think Mark picked up the gist of the question a little better.

  5. #5
    SitePoint Addict Quaint's Avatar
    Join Date
    May 2004
    Location
    Netherlands
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by markl999
    somepage.php?css=darkblue

    Then wherever you link in the stylesheet just do something like:
    PHP Code:
    $stylesheet = isset($_GET['css']) ? $_GET['css'] : 'default';
    $stylesheet file_exists('/css/'.$stylesheet.'.css') ? $stylesheet 'default';
    echo 
    '<link href="/css/'.$stylesheet.'.css" rel="stylesheet" type="text/css" />'
    nice nice nice nice nice nice nice

    Quaint Tech
    - Blog on web development and web technology.


Bookmarks

Posting Permissions

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