Results 1 to 2 of 2

Thread: Can I put a php include inside a CSS DIV box?

  1. #1
    Join Date
    Jun 2006
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can I put a php include inside a CSS DIV box?

    Not sure if this is the right board or if it should be in the PHP section, but here goes:

    Here is my situation, in my CSS style sheet I have several div box definitions, like so:

    Code:
    #box3 { float:left;
    margin-right: 0px;
    margin-top: 0px;
    height: 75px;
    width: 800px;
    border: none;
    padding: 0px;
    background: clear;
    }
    I usually will put this at the bottom of a page, then include a list of links by pointing at a php file by putting this in my page body:

    Code:
    <div id="box3" class="menu">
    <?php include( 'php/topmenu.php' ); ?>
    </div>
    Now, this works great, because when I change a link in the php file, it is propogated across all pages that use said file.

    However, I am building a new site, and using the same type of stylesheet, and what I would like to do is somehow embed the links right in the CSS style sheet to take one step away.

    I tried this in my stylesheet, but it didn't work:

    Code:
    #box3 { float:left;
    margin-right: 0px;
    margin-top: 0px;
    height: 75px;
    width: 800px;
    border: none;
    padding: 0px;
    background: clear;
    <?php include( 'php/topmenu.php' ); ?>
    }
    The reason I want to do this is I've already built quite a few pages with the "box3" div at the bottom of them, and now decided to put a set of links in them, and I was wondering if there was some way to just embed the php links file in the CSS stylesheet itself, so save me from opening each page one at a time and inserting the <?php include( 'php/topmenu.php' ); ?> in each one. (I suppose I could do a mass edit in textpad, but it would probably take me longer to figure out how to so that than just doing each page one at a time)

    If this is possible I'd really appreciate someone showing me how..


    thanks!

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Don't understand what you mean, links can't be in a css file.

    Can you post the code that php/topmenu.php contains?

    Short answer: yes to this

    PHP Code:
    <div id="box3" class="menu">
    <?php include( 'php/topmenu.php' ); ?>
    </div>
    No to this

    Code:
    #box3 { float:left;
    margin-right: 0px;
    margin-top: 0px;
    height: 75px;
    width: 800px;
    border: none;
    padding: 0px;
    background: clear;
    <?php include( 'php/topmenu.php' ); ?>
    }
    if this is in an external stylesheet ie something.css. This is because it won't be processed as php because it ends in .css.

    You could put that in the head of your document in style tags. That would delete the purpose though as you'd have to do each page individually still.
    Last edited by bluewalrus; 03-11-2010 at 07:42 PM.
    Corrections to my coding/thoughts welcome.

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
  •