Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,873
    Plugin Contributions
    96

    Default Children support for category-specific stylesheet overrides

    This new feature in v1.5.1 sounds like a great idea, but I'm not sure how practical it is. I composed a small test for a stock Zen Cart v1.5.1 install, creating three files in /includes/templates/classic/css:

    c_54_children.css: .centerColumn { color: green; } ... New v1.2
    c_54_55.css: .centerColumn { color: blue; } ... New v1.2 ... Discount Qty
    p_127.css: .centerColumn { color: red; } ... New v1.2 ... Discount Qty ... Normal Product

    My expectation and the actual text color for the various pages are as follows:
    Code:
    main_page=index&cPath=54, expected=black, actual=green
    main_page=index&cPath=54_56, expected=green, actual=green
    main_page=index&cPath=54_55, expected=blue, actual=green
    main_page=product_info&cPath=54_55&products_id=127, expected=red, actual=green
    My expectation for cPath=54 being black is that it's not a child of itself so the _children file shouldn't have been loaded. I expected that the c_54_55.css file would override the c_54_children.css in standard CSS fashion; ditto with the p_127.css as it was more specific.

    Am I simply harboring false expectations or is this a problem with the way the _children.css files are loaded?

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Children support for category-specific stylesheet overrides

    This was discussed a while back: CSSreadme clarifications
    The issue is partly terminology (_children implies excluding the referenced category and can lead to confusion) and partly function (the broad _children files load after specific category files, not before as they ought to).

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,873
    Plugin Contributions
    96

    Default Re: Children support for category-specific stylesheet overrides

    Thanks, Glenn. I was pretty sure that I'd seen the discussion elsewhere but couldn't find it searching for _children. Looking at the code in html_header.php, it's obvious that the c_xx_children.css files are currently loaded after all other stylesheets for the page except for the print_*.css files.
    Last edited by lat9; 14 Nov 2012 at 01:43 PM.

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,873
    Plugin Contributions
    96

    Default Re: Children support for category-specific stylesheet overrides

    I've taken the liberty of recoding the portion of the CSS-loading section of /includes/templates/template_default/common/html_header.php to adhere to the CSS_read_me.txt file updates that Glenn provided in his referenced suggestion. A more-specific c_xx_yy.css file is loaded after a c_xx_yy_children.css file and a p_xxx.css file is loaded after that ...
    Code:
    /**
     * load stylesheets on a per-page/per-language/per-product/per-manufacturer/per-category basis. Concept by Juxi Zoza.
     */
      $manufacturers_id = (isset($_GET['manufacturers_id'])) ? $_GET['manufacturers_id'] : '';
      $tmp_products_id = (isset($_GET['products_id'])) ? (int)$_GET['products_id'] : '';
      $tmp_pagename = ($this_is_home_page) ? 'index_home' : $current_page_base;
    
      if ($current_page_base == 'page' && isset($ezpage_id)) $tmp_pagename = $current_page_base . (int)$ezpage_id;
      $sheets_array = array('/' . $_SESSION['language'] . '_stylesheet',
                            '/' . $tmp_pagename,
                            '/' . $_SESSION['language'] . '_' . $tmp_pagename
                           );
    
      $tmp_cats = explode('_', $cPath);
      $value = '';
      foreach($tmp_cats as $val) {
        $value .= $val;
        $sheets_array[] =   '/c_' . $value . '_children';
        $sheets_array[] =   '/' . $_SESSION['language'] . '_c_' . $value . '_children';
        $value .= '_';
      }
      
      $sheets_array2 = array('/c_' . $cPath,
                             '/' . $_SESSION['language'] . '_c_' . $cPath,
                             '/m_' . $manufacturers_id,
                             '/' . $_SESSION['language'] . '_m_' . (int)$manufacturers_id,
                             '/p_' . $tmp_products_id,
                             '/' . $_SESSION['language'] . '_p_' . $tmp_products_id
                            );
                            
      $sheets_array = array_merge($sheets_array, $sheets_array2);
      
      while(list ($key, $value) = each($sheets_array)) {
        //echo "<!--looking for: $value-->\n";
        $perpagefile = $template->get_template_dir('.css', DIR_WS_TEMPLATE, $current_page_base, 'css') . $value . '.css';
        if (file_exists($perpagefile)) echo '<link rel="stylesheet" type="text/css" href="' . $perpagefile .'" />'."\n";
      }

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Children support for category-specific stylesheet overrides

    Thanks! I was thinking about doing that... I have an Improved Stylesheet Calls mod in Plugins that does some of the things the new html_header does, and a couple that it still doesn't do (like ez-page chapter stylesheets), as well as efficiency improvements. I might take a stab at integrating these in the spirit of offering code examples to work from.

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,873
    Plugin Contributions
    96

    Default Re: Children support for category-specific stylesheet overrides

    Sounds good, Glenn. I look forward to seeing your updates.

 

 

Similar Threads

  1. v151 Category Specific Access Restriction (CSAR) - [Support Thread]
    By frank18 in forum All Other Contributions/Addons
    Replies: 187
    Last Post: 12 Sep 2021, 09:41 PM
  2. v138a Menu shows one category's children on homepage
    By rand486 in forum General Questions
    Replies: 11
    Last Post: 22 May 2012, 04:42 PM
  3. Page Specific stylesheet CSS for EZpages?
    By khopek in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 6 Apr 2010, 01:18 AM
  4. A seperate sidebox box for each top category and its children?
    By arniesbarmyarmy in forum Basic Configuration
    Replies: 4
    Last Post: 22 Oct 2009, 10:44 AM
  5. specific banner to show for specific category
    By vijay in forum Basic Configuration
    Replies: 1
    Last Post: 26 Aug 2009, 01:19 PM

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