Thread: php & css

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    89
    Rep Power
    11

    php & css


    ok I have a theme sheet. that defines global colors: (just a snipet)

    global $color;
    $color[0] = '#eeeeee'; // (mid-dark gray) Content Area
    $color[1] = '#F88888'; // (light red) Quoted Replies in Emails

    I have a style sheet and works with the colors: (again just a snipet)

    .content {
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: $color[0];
    border-right-color: $color[0];
    border-bottom-color: $color[0];
    border-left-color: $color[0];
    }

    and lastly I have a table with the class="content" tag on my webpage.

    With all these 3 elements, I'm not getting the style I specified. I am getting the borders.. just not the right colors. I know I am missing something.

    Everything with the global colors & the style sheet are working fine. Like I said they are snipets. (just the parts I showed were the concern)

    Can someone clue me in?
    Thanks.
    Last edited by sev247; March 1st, 2004 at 04:31 PM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Posts
    809
    Rep Power
    16
    Is your stylsheet within the header of the page or is it in a seperate file?

    If it's in the header you nee to echo the variable:
    PHP Code:
    .content {
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: <?php echo $color[0?>;
    border-right-color: <?php echo $color[0?>;
    border-bottom-color: <?php echo $color[0?>;
    border-left-color: <?php echo $color[0?>;
    }
    If it's in a seperate file then you have a whole 'nuther set of problems.
    IT's got to be a .php page to be parsed, and again variables need to be echo'd
  4. #3
  5. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1099
    If the above doesn't work, check the resulting HTML (the result of combining all three elements) and make sure it looks like it should. BTW, here's a simplified version of your stylesheet:
    PHP Code:
    <? # ignore this tag set ?>
    .content
      {
      border: 1px solid <?=$color[0]?>;
      border-top: 0px none;
      }
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    89
    Rep Power
    11
    I had the CSS as a separate file. I then found away to add the .content style to the page when it loads and I view the source this is how it prints out. (using the 2nd example you gave me. it did the same thing for the first. minus the "=" with php echo)

    border-top-color: <?= ?>;
    border-right-color: <?= ?>;
    border-bottom-color: <?= ?>;
    border-left-color: <?= ?>;
    }

    Thanks for your time. I do appreciate it.
    Last edited by sev247; March 1st, 2004 at 05:54 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Posts
    809
    Rep Power
    16
    How bout showing us the code for the first part of your page.

    It looks like the page isn't being parsed.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    89
    Rep Power
    11
    <?php

    /** Include required files from SM */
    require_once(SM_PATH . 'functions/strings.php');
    require_once(SM_PATH . 'functions/html.php');
    require_once(SM_PATH . 'functions/imap_mailbox.php');
    require_once(SM_PATH . 'functions/global.php');

    /**
    * Output a SquirrelMail page header, from <!doctype> to </head>
    * Always set up the language before calling these functions.
    *
    * @param string title the page title, default SquirrelMail.
    * @param string xtra extra HTML to insert into the header
    * @param bool do_hook whether to execute hooks, default true
    * @return void
    */
    function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) {
    global $squirrelmail_language;

    if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
    global $base_uri;
    }
    global $theme_css, $custom_css, $pageheader_sent;

    echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
    "\n\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) .

    "\n<head>\n";

    if ( !isset( $custom_css ) || $custom_css == 'none' ) {
    if ($theme_css != '') {
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />";
    }
    } else {
    echo '<link rel="stylesheet" type="text/css" href="' .
    $base_uri . 'themes/css/'.$custom_css.'" />';
    }

    if ($squirrelmail_language == 'ja_JP') {
    echo "<!-- \xfd\xfe -->\n";
    echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n";
    }

    if ($do_hook) {
    do_hook('generic_header');
    }

    echo "\n<title>$title</title>$xtra\n";

    /* work around IE6's scrollbar bug */
    echo <<<ECHO
    <style type="text/css">
    <!--
    /* avoid stupid IE6 bug with frames and scrollbars */
    body {
    voice-family: "\"}\"";
    voice-family: inherit;
    width: expression(document.documentElement.clientWidth - 30);
    }
    .content {
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: <?php echo $color[0] ?>;
    border-right-color: <?php echo $color[0] ?>;
    border-bottom-color: <?php echo $color[0] ?>;
    border-left-color: <?php echo $color[0] ?>;
    }
    -->
    </style>

    ECHO;

    echo "\n</head>\n\n";

    /* this is used to check elsewhere whether we should call this function */
    $pageheader_sent = TRUE;
    }

    /**
    * Sa
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Posts
    809
    Rep Power
    16
    PHP Code:
     .content {
    border-right-width1px;
    border-bottom-width1px;
    border-left-width1px;
    border-top-stylenone;
    border-right-stylesolid;
    border-bottom-stylesolid;
    border-left-stylesolid;
    border-top-color: {$color[0]};
    border-right-color: {$color[0]};
    border-bottom-color: {$color[0]};
    border-left-color: {$color[0]};

  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    89
    Rep Power
    11
    ok I posted that... refreshed the page.. checked the source:

    <!--
    /* avoid stupid IE6 bug with frames and scrollbars */
    body {
    voice-family: "\"}\"";
    voice-family: inherit;
    width: expression(document.documentElement.clientWidth - 30);
    }
    .content {
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: ;
    border-right-color: ;
    border-bottom-color: ;
    border-left-color: ;
    }

    -->
    </style>

    I swear its like invasion of the code snatchers. Again thanks for your help.. but I am stumped.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Posts
    809
    Rep Power
    16
    Echo $color[0] directly, see if it's actually set.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    89
    Rep Power
    11
    its doing the same thing when I put the echo tag somewhere else... BUT here is more of that page: These do work they are showing up as #000000 or whatever color=[0] is set to.

    echo "<body text=\"$color[0]\" bgcolor=\"$color[0]\" link=\"$color[0]\" vlink=\"$color[0]\"

    alink=\"$color[7]\" $onload>\n\n";
    /** Here is the header and wrapping table **/
    $shortBoxName = imap_utf7_decode_local(
    readShortMailboxName($mailbox, $delimiter));
    if ( $shortBoxName == 'INBOX' ) {
    $shortBoxName = _("INBOX");
    }
    echo "<a name=\"pagetop\"></a>\n"
    . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0"

    cellpadding="2"' ) ."\n"
    . html_tag( 'tr', '', '', $color[0] ) ."\n"
    . html_tag( 'td', '', 'left' ) ."\n";
    if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) {
    echo ' ' . _("<font color=$color[0]>Current Folder</font>") . ": <font

    color=$color[4]><b>$shortBoxName&nbsp;</b></font>\n";
    } else {
    echo '&nbsp;';
    }
    echo " </td>\n"
    . html_tag( 'td', '', 'right' ) ."<b>\n";
    displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top);
    echo "</b></td>\n"
    . " </tr>\n"
    . html_tag( 'tr', '', '', $color[0] ) ."\n"
    . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' )
    : html_tag( 'td', '', 'left' ) )
    . "\n";
    $urlMailbox = urlencode($mailbox);
    echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage);
    echo "&nbsp;&nbsp;\n";
    Last edited by sev247; March 1st, 2004 at 06:48 PM.
  20. #11
  21. Learn logic, not PHP!
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    Hong Kong SAR
    Posts
    1,006
    Rep Power
    12
    Looks like that your stylesheet is within the displayHtmlHeader function. You need to global $color to make them visible.
    error_reporting(E_ALL) and echo($debug_message) may help to heal your headache.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    89
    Rep Power
    11
    That is the problem. Global colors is working just fine. I have global colors, a style sheet, and a php file.

    They all work fine. but when it comes to telling the specific color of a style tag using global colors... it doesnt take.

    So my work around idea was to add the style tag to the page directly. the style tag appears, but the $color[0] tag disappears leaving an empty space where the hex color tag should be.

    Looks like this is the end of the road for this topic. Thanks to the few who tried to help. If anyone has anymore ideas.. aside from the few posted here... please post. thanks!
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    65
    Rep Power
    11
    maybe just use echo strval($color);

    and set both colors as variables?

    thats what i did when i did this same issue.
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    89
    Rep Power
    11
    well there was no REAL fix.. but I decided to put the code a little lower on the page and *poof* it works.

    here is what I ended up with right before the body tag:

    echo <<<ECHO

    <style type="text/css">
    <!--

    .content {
    border-right-width: 1px;
    border-bottom-width: 1px;
    border-left-width: 1px;
    border-top-style: none;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-right-color: $color[0];
    border-bottom-color: $color[0];
    border-left-color: $color[0];
    }
    -->
    </style>

    ECHO;

    again thanks for all the help. I dont know why it worked lower on the page.. kind of new to PHP myself. Again thanks to all who helped.
  28. #15
  29. Learn logic, not PHP!
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    Hong Kong SAR
    Posts
    1,006
    Rep Power
    12
    Originally Posted by sev247
    That is the problem. Global colors is working just fine. I have global colors, a style sheet, and a php file.

    They all work fine. but when it comes to telling the specific color of a style tag using global colors... it doesnt take.

    So my work around idea was to add the style tag to the page directly. the style tag appears, but the $color[0] tag disappears leaving an empty space where the hex color tag should be.

    Looks like this is the end of the road for this topic. Thanks to the few who tried to help. If anyone has anymore ideas.. aside from the few posted here... please post. thanks!
    What I meant by global $color is that you need to define that inside your function call otherwise the function will not see it.

    PHP Code:
    function displayHtmlHeader$title 'SquirrelMail'$xtra ''$do_hook TRUE ) {
    global 
    $squirrelmail_language;

    if ( !
    sqgetGlobalVar('base_uri'$base_uriSQ_SESSION) ) {
    global 
    $base_uri;
    }

    becomes

    function displayHtmlHeader$title 'SquirrelMail'$xtra ''$do_hook TRUE ) {
    global 
    $color;
    global 
    $squirrelmail_language;

    if ( !
    sqgetGlobalVar('base_uri'$base_uriSQ_SESSION) ) {
    global 
    $base_uri;

    A function will assume everything local if you don't define it global. In your function, you didn't define $color as global and hence, when you use it within your stylesheet, you got nothing. If you use error_reporting(E_ALL), you will receive a PHP Notice about that problem.
    error_reporting(E_ALL) and echo($debug_message) may help to heal your headache.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo