SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question dynamic css generated with php problem.. help needed please!!

    i have a style sheet that is generated by php. most of the time this renders ok but ocassionally, when clicking a link on the index page that reloads itself, the page reloads with content present but without any of the style being applied - i realise what is happening but have no idea how to prevent it....

    1. the index page is called
    2. in most cases the css.php file linked in the header is parsed and the style is applied before the rest of the index page renders
    3. in some cases the rest of the index page is rendering before the server has had a chance to parse the css.php file and feed it to index as a style sheet

    what i need is for some means of checking that the style sheet is available (i.e parsed by php) before the rest of the page that uses the style is loaded... ideas anyone??

    here is the code in my index.php:
    PHP Code:
    <?php 
        session_start
    (); 
        
    error_reporting(E_ALL);     
         
        include_once (
    "logic.php"); 
         
        if(!
    session_is_registered ('coords')) 
        { 
            
    $coords create_coords(); 
            
    $projects listdirs('/img'); 
            
    $projectsno count($projects); 
            
    $arrow get_arrow($projectsno); 
             
            
    session_register ('coords'); 
            
    session_register ('projectsno'); 
            
    session_register ('projects'); 
            
    session_register ('arrow'); 
             
            
    $HTTP_SESSION_VARS ['coords'] = $coords
            
    $HTTP_SESSION_VARS ['projectsno'] = $projectsno
            
    $HTTP_SESSION_VARS ['projects'] = $projects;         
            
    $HTTP_SESSION_VARS ['arrow'] = $arrow
             
        } 
                 
         
        
    ?> 
         
        <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 
        'http://www.w3.org/TR/xhtml11/DTD/xhtml1-transitional.dtd'> 
        <html xmlns='http://www.w3.org/1999/xhtml'> 
        <head> 
        <link href='counterspace_4_css.php' rel='stylesheet' type='text/css'/> 
        <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /> 
        <title>c o u n t e r s p a c e</title> 
         
         
        </head> 
         
        <body>
    and here is the code in my css.php file that generates the style sheet:

    PHP Code:
    <?php 
         
        
    for ($i 0$i $projectsno$i++) 
        { 
            
    $place $coords[$i]; 
            echo 
    "    #link$i { 
                    width: 16px; 
                    height: 16px; 
                    position: absolute; 
                    z-index: 3; 
                    border: 0px; 
                    margin-left: 
    $place[0]px; 
                    margin-top: 
    $place[1]px;} 
                     
                    "

        } 
    ?> 

    body { 
        font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; 
        font-size: 12px; 
        margin:    0px 0px 0px 0px; 
        color: #99cccc; 

    .content { 
        margin: 0px 0px 0px 0px; 
        background-color: #1e120c; 
        width: 100px; 
        height: 500px;     
        } 
         
    #top { 
        background-color: #1e120c; 
        width: 100%; 
        height: 500px; 
        position: relative; 
        z-index: 3; 
    }
    help please!

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    I'm afraid I have no experience with dynamically generated css and the usual problems I've read about are with the css not being cached and the correct content headers not being sent. There are solutions in the link above.

    I will move the post to the php forum as I think its more appropriate there

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks paul, did wonder about putting it in the css forum!

    that looks like a good article.. will let you know if i solve it

  4. #4
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I produce the CSS on my site with PHP but have not run into such a problem.

    Number 3 is certainly not true. The browser waits for the css before displaying the page. One possibility is the browser doesn't know if the CSS file has completely arrived because you are not sending the content length header.

    Post a link to the stylesheet.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this will give you the css generated by the css.php

    css.php

    this is the index page..

    index.php

    if you click the arrows at the bottom ocassionally you will see the style disappear (the arrows all appear at the top of the page with no brown area)

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bokehman
    I produce the CSS on my site with PHP but have not run into such a problem.

    Number 3 is certainly not true. The browser waits for the css before displaying the page. One possibility is the browser doesn't know if the CSS file has completely arrived because you are not sending the content length header.

    Post a link to the stylesheet.
    i have tried pasting the style sheet into the <head> of my index and the problem disappears completely so it must be related to using an external file...

    can you give me an example of how to use the content length header?

    thanks

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    74
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    further update - it doesnt happen in firefox!

  8. #8
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't faulter for me and the CSS has a content length header.


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
  •