Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2006
    Posts
    50
    Plugin Contributions
    0

    Default Adding IE conditional stylesheet

    ZC 1.3.5

    Could someone lend a dab of php expertise on adding a stylesheet that has a conditional into the header? I may about have it but for a syntax error...

    This stylesheet conditional works fine for me in other static sites I've done.
    <!--[if gte ie 5.5000]><link rel="stylesheet" type="text/css" href="css/stylesheet_ie.css" /><![endif]-->
    This is what I'm tryingwith the html_header.php file in my_custom common folder; note the closing tag for the conditional:

    /**
    * load all template-specific stylesheets, named like "style*.css", alphabetically
    */
    $directory_array = $template->get_template_part($template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css'), '/^style/', '.css');
    while(list ($key, $value) = each($directory_array)) {
    echo '<link rel="stylesheet" type="text/css" href="' . $template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css') . '/' . $value . '" />'."\n";
    }

    /**
    * Special IE Overide -- load all template-specific stylesheets, named like "style*.css", alphabetically
    */
    $directory_array = $template->get_template_part($template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'cssie'), '/^style/', '.css');
    while(list ($key, $value) = each($directory_array)) {
    echo '<!--[if gte ie 5.5000]><link rel="stylesheet" type="text/css" href="' . $template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'cssie') . '/' . $value . '" />'."\n" . '<![endif]-->' .;
    }
    Last edited by oceano; 18 Sep 2006 at 05:35 PM.

  2. #2
    Join Date
    May 2004
    Location
    Hong Kong
    Posts
    1,291
    Plugin Contributions
    1

    Default Re: Adding IE conditional stylesheet

    My approach, modify the following file.
    includes/templates/YOUR_TEMPLATE/common/tpl_header.php

    Please note below is my code for IE also.
    HTML Code:
    <!-->
    <link href="/includes/templates/future_zen_4/css/ie.css" media="screen" rel="stylesheet" title="IE Style" type="text/css" />
    <!-->
    Put it, in the end of the below code section, and before the:
    <!--bof-header logo and navigation display-->

    PHP Code:
    <?php
    /**
     * Common Template - tpl_header.php
     *
     * this file can be copied to /templates/your_template_dir/pagename<br />
     * example: to override the privacy page<br />
     * make a directory /templates/my_template/privacy<br />
     * copy /templates/templates_defaults/common/tpl_footer.php to /templates/my_template/privacy/tpl_header.php<br />
     * to override the global settings and turn off the footer un-comment the following line:<br />
     * <br />
     * $flag_disable_header = true;<br />
     *
     * @package templateSystem
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: tpl_header.php 4066 2006-08-06 05:50:06Z ajeh $
    */
    ?>

    <?php
      
    // Display all header alerts via messageStack:
      
    if ($messageStack->size('header') > 0) {
        echo 
    $messageStack->output('header');
      }
      if (isset(
    $_GET['error_message']) && zen_not_null($_GET['error_message'])) {
      echo 
    htmlspecialchars(urldecode($_GET['error_message']));
      }
      if (isset(
    $_GET['info_message']) && zen_not_null($_GET['info_message'])) {
       echo 
    htmlspecialchars($_GET['info_message']);
    } else {

    }
    ?>
    <!-->
    <link href="/includes/templates/future_zen_4/css/ie.css" media="screen" rel="stylesheet" title="IE Style" type="text/css" />
    <!-->
    <!--bof-header logo and navigation display-->
    A New Starter again

  3. #3
    Join Date
    Aug 2006
    Posts
    50
    Plugin Contributions
    0

    Default Re: Adding IE conditional stylesheet

    Thanks for the suggestions!

    However I still find that it did not work for me. The line of code ends up below the closing head tag.

    I was also hoping to use the conditional statement for IE 5.5 and 6 (thus excluding IE 5.0) that I had in there, a minor point.

    I think this is going to take some more experimenting unless someone else has another idea for getting this into the head of the page - below the other style sheets.

  4. #4
    Join Date
    May 2004
    Location
    Hong Kong
    Posts
    1,291
    Plugin Contributions
    1

    Default Re: Adding IE conditional stylesheet

    If I don't get wrong,
    you mean for the IE, to duplicate the override and the file structures of the css.

    You want to put all the override css for IE to the directory of cssie,
    as:
    includes/templates/YOUR_TEMPLATE/cssie/stylesheet_*.css

    Anyway you code has something wrong and I had changed it a bit.
    Please improve it further by yourself.

    And the code as follow:
    PHP Code:
    /**
     * Special IE Overide -- load all template-specific stylesheets, named like "style*.css", alphabetically
     */
      
    $directory_array $template->get_template_part($template->get_template_dir('.css',DIR_WS_TEMPLATE$current_page_base,'cssie'), '/^style/''.css');
      while(list (
    $key$value) = each($directory_array)) {
      echo 
    '<!--[if gte ie 5.5000]><link rel="stylesheet" type="text/css" href="' $template->get_template_dir('.css',DIR_WS_TEMPLATE$current_page_base,'cssie') . '/' $value '" />' '<![endif]-->'."\n";

    And the following is the result page source for the css links, they sit befor the </head>.
    Please note, in testing I only duplicate the files in ./css to ./cssie for demo.
    HTML Code:
    <link rel="stylesheet" type="text/css" href="includes/templates/future_zen_4/css/stylesheet.css" />
    <link rel="stylesheet" type="text/css" href="includes/templates/future_zen_4/css/stylesheet_betterCategoriesEzInfo.css" />
    <link rel="stylesheet" type="text/css" href="includes/templates/future_zen_4/css/stylesheet_my.css" />
    <link rel="stylesheet" type="text/css" href="includes/templates/future_zen_4/css/stylesheet_tree.css" />
    <!--[if gte ie 5.5000]><link rel="stylesheet" type="text/css" href="includes/templates/future_zen_4/cssie/stylesheet.css" /><![endif]-->
    <!--[if gte ie 5.5000]><link rel="stylesheet" type="text/css" href="includes/templates/future_zen_4/cssie/stylesheet_betterCategoriesEzInfo.css" /><![endif]-->
    <!--[if gte ie 5.5000]><link rel="stylesheet" type="text/css" href="includes/templates/future_zen_4/cssie/stylesheet_my.css" /><![endif]-->
    <!--[if gte ie 5.5000]><link rel="stylesheet" type="text/css" href="includes/templates/future_zen_4/cssie/stylesheet_tree.css" /><![endif]-->
    </head>
    Last edited by seethrou; 18 Sep 2006 at 10:21 PM. Reason: added info.
    A New Starter again

  5. #5
    Join Date
    Aug 2006
    Posts
    50
    Plugin Contributions
    0

    Default Re: Adding IE conditional stylesheet

    Thanks very much, that did it. Nice of you to help. I'll probably arrange things slightly different but this got me on the right track.

    kind regards /mark

  6. #6
    Join Date
    May 2004
    Location
    Hong Kong
    Posts
    1,291
    Plugin Contributions
    1

    Default Re: Adding IE conditional stylesheet

    Oops!
    Find a bug for the address in the above code!

    Code:
    <!-->
    <link href="/includes/templates/opium_custom/css/custom_ie.css" media="screen" rel="stylesheet" title="IE Style" type="text/css" />
    <!-->
    It should be no slash "/" before the includes.
    Code:
    <!-->
    <link href="includes/templates/opium_custom/css/custom_ie.css" media="screen" rel="stylesheet" title="IE Style" type="text/css" />
    <!-->
    And it should be:
    ==============
    My approach, modify the following file.
    includes/templates/YOUR_TEMPLATE/common/tpl_header.php

    Please note below is my code for IE also.
    HTML Code:
    <!-->
    <link href="includes/templates/future_zen_4/css/ie.css" media="screen" rel="stylesheet" title="IE Style" type="text/css" />
    <!-->
    Put it, in the end of the below code section, and before the:
    <!--bof-header logo and navigation display-->

    PHP Code:
    <?php
    /**
     * Common Template - tpl_header.php
     *
     * this file can be copied to /templates/your_template_dir/pagename<br />
     * example: to override the privacy page<br />
     * make a directory /templates/my_template/privacy<br />
     * copy /templates/templates_defaults/common/tpl_footer.php to /templates/my_template/privacy/tpl_header.php<br />
     * to override the global settings and turn off the footer un-comment the following line:<br />
     * <br />
     * $flag_disable_header = true;<br />
     *
     * @package templateSystem
     * @copyright Copyright 2003-2006 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: tpl_header.php 4066 2006-08-06 05:50:06Z ajeh $
    */
    ?>

    <?php
      
    // Display all header alerts via messageStack:
      
    if ($messageStack->size('header') > 0) {
        echo 
    $messageStack->output('header');
      }
      if (isset(
    $_GET['error_message']) && zen_not_null($_GET['error_message'])) {
      echo 
    htmlspecialchars(urldecode($_GET['error_message']));
      }
      if (isset(
    $_GET['info_message']) && zen_not_null($_GET['info_message'])) {
       echo 
    htmlspecialchars($_GET['info_message']);
    } else {

    }
    ?>
    <!-->
    <link href="includes/templates/future_zen_4/css/ie.css" media="screen" rel="stylesheet" title="IE Style" type="text/css" />
    <!-->
    <!--bof-header logo and navigation display-->
    A New Starter again

  7. #7

    Default Re: Adding IE conditional stylesheet

    Worked great for me. Thanks for the tip.

  8. #8
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Adding IE conditional stylesheet

    Or you could just use the Zen Cart mod designed to do exactly this and puts the code into the html_header file which is more appropriate than tpl_header file.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

 

 

Similar Threads

  1. Adding conditional code to emails
    By Scott_C in forum General Questions
    Replies: 7
    Last Post: 17 May 2010, 09:15 AM
  2. HowTo include an IE Conditional Comments stylesheet
    By joelfarris in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 9 Jun 2007, 02:33 AM
  3. conditional stylesheet
    By tomzo in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 25 Mar 2007, 08:03 PM
  4. Need the Zen-ese to call stylesheet through Conditional Comment
    By beejay in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 20 Dec 2006, 02:32 PM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR