Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / CSS per category doesn't seem to work.

CSS per category doesn't seem to work.

Locked

Views: 3,653

Results 1 to 15 of 15
This thread is locked. New replies are disabled.
16 Jul 2006, 12:26 AM
#1
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

CSS per category doesn't seem to work.

I'm trying to make a category specific css file, but it shows up on every page, not just in the targeted category. The category_id = 1, and i have tried all of the following combinations (there are no subcategories)

c_1.css
c_1_0.css
c_1_00.css
c_01_00.css

What am I doing wrong?

Thanks!

16 Jul 2006, 3:18 AM
#2
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: CSS per category doesn't seem to work.

Make sure the c_?_?.css matches the "cpath"

/index.php?main_page=index&cPath=15

in this case c_15_00.css

16 Jul 2006, 4:02 AM
#3
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

Re: CSS per category doesn't seem to work.

Thanks for the response, but that is not the problem. The problem is that the css file ALWAYS is displayed inside and outside the category (and yes, I'm using the correct "cpath." If I put a stylesheet in the css folder, and call it c_15_00.css or whatever, it ALWAYS shows up. There is no filtering happening. I checked the html_header.php file to see if that was the problem but its not.

clydejones:

Make sure the c_?_?.css matches the "cpath"

/index.php?main_page=index&cPath=15

in this case c_15_00.css

16 Jul 2006, 4:13 AM
#4
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: CSS per category doesn't seem to work.

Do you have a URL i can take a peek at?

16 Jul 2006, 4:44 AM
#5
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: CSS per category doesn't seem to work.

I took a look and apparently you have something commented out.

http://www.moissaniteco.com/13/includes/templates/Custom/css/c_25_00.css

/* .solCt a{background:url(../images/Sidebox/catbox_roll.gif) no-repeat !important;} */

If it's commented out, its not going to show up.

16 Jul 2006, 4:46 AM
#6
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

Re: CSS per category doesn't seem to work.

Yeah, i know. The point is the css shows up on every page. So what ever css I have in that stylesheet WILL show up on every page, not just in the specific category.

16 Jul 2006, 5:44 AM
#7
clydejones avatar

clydejones

Deceased

Join Date:
Nov 2005
Location:
Colorado Springs, CO USA
Posts:
7,017
Plugin Contributions:
12

Re: CSS per category doesn't seem to work.

The style sheet will load in any case.

You had 3 or 4 that were loading.

If you make c_25.css unique for that category it will only take effect when that category is present.

Take a look at mysticmountainnaturals.com/newshop

click on MMN for women and notice how the header image changes, then click the home link or any other link and watch the header image change.

If you click on any of the sub categories under MMN for women the header image won't change because they are sub categories.

16 Jul 2006, 2:43 PM
#8
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

Re: CSS per category doesn't seem to work.

Yes I understand that. The point still is on your site, when you are not in category 15, the stylesheet c_15_00.css DOES NOT APPEAR in the html. On my site, for whatever reason (apparently something is broken) the stylesheet ALWAYS appears even though it is name for a specific category.

16 Jul 2006, 2:53 PM
#9
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

Re: CSS per category doesn't seem to work.

Weird! I went and slept on it, did EXACTLY the same thing as last night, and now it works. Too bizarre. For those who are reading this, I've found that for single digit categories, c_1_00 works while c_01_00 does not, at least for me.

16 Jul 2006, 3:43 PM
#10
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

Re: CSS per category doesn't seem to work.

Maybe there is a glitch with 1.3.01. If you look at the first category, Solitaires, the css c_1_00.css appears. If you navigate to another category it is correctly filtered out. BUT if you go to any other page outside of the category listing (ie shopping cart, about us, contact us, etc.) all of the category specific stylesheets are not filtered out and appear! :Flush:

Look here: http://www.moissaniteco.com/13/moissanite-solitaires-c-1.html

16 Jul 2006, 3:53 PM
#11
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

Re: CSS per category doesn't seem to work.

It IS a bug in 1.3.01!!! I just downloaded the 1.3.02 and replaced the code from the new html_header and it works!

16 Jul 2006, 4:00 PM
#12
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

Re: CSS per category doesn't seem to work.

Maybe there is more that needs to be fixed than just the html header. It works BUT it is not working perfectly. The single digit categories are not working correctly. For example, when I click in category 1, it is also picking up category 10 and category 13 because of the "1". Likewise, category 2 is also picking up category 25 and category 26. Click on the link below to observe the behavior (category 1 = Solitaires, category 2 = Engagement Rings).

16 Jul 2006, 5:05 PM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: CSS per category doesn't seem to work.

in html_header.php, change lines 57-58:php '/^c_' . (int)$cPath .'.css/', '/^' . $_SESSION['language'] . '_c_' . (int)$cPath . '/', to:```php
'/^c_' . $current_category_id .'/',
'/^' . $_SESSION['language'] . 'c' . $current_category_id . '/',



This way you'll get it to work like this:

c_1.css
c_2.css
c_33.css
c_47.css
etc

don't try joining several together at once like this:
c_1_3_18.css ... this won't work
Instead, just use c_18.css
(This way, if you move a sub-category into a different place, your formatting will still follow it, etc.)
16 Jul 2006, 5:20 PM
#14
voltage avatar

voltage

Totally Zenned

Join Date:
Apr 2005
Location:
Houston, TX
Posts:
1,356
Plugin Contributions:
1

Re: CSS per category doesn't seem to work.

Hi Dr Byte,
I made the edit, but I am still getting the same wierd behavior with category 1 & 2. Here is my html_header

<?php /** * Common Template * * outputs the html header. i,e, everything that comes before the \</head\> tag <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: html_header.php 3688 2006-06-02 00:12:18Z drbyte $ */ /** * load the module for generating page meta-tags */ require(DIR_WS_MODULES . zen_get_module_directory('meta_tags.php')); /** * output main page HEAD tag and related headers/meta-tags, etc */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" <?php echo HTML_PARAMS; ?>> <head> <title><?php echo META_TAG_TITLE; ?></title> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>" /> <meta name="keywords" content="<?php echo META_TAG_KEYWORDS; ?>" /> <meta name="description" content="<?php echo META_TAG_DESCRIPTION; ?>" /> <meta http-equiv="imagetoolbar" content="no" /> <meta name="author" content="The Zen Cart™ Team and others" /> <meta name="generator" content="shopping cart program by Zen Cart™, http://www.zen-cart.com" /> <?php if (defined('ROBOTS_PAGES_TO_SKIP') && in_array($current_page_base,explode(",",constant('ROBOTS_PAGES_TO_SKIP'))) || $current_page_base=='down_for_maintenance') { ?> <meta name="robots" content="noindex, nofollow" /> <?php } ?> <?php if (defined('FAVICON')) { ?> <link rel="icon" href="<?php echo FAVICON; ?>" type="image/x-icon" /> <link rel="shortcut icon" href="<?php echo FAVICON; ?>" type="image/x-icon" /> <?php } //endif FAVICON ?> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG ); ?>" /> <?php /** * 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"; } /** * load stylesheets on a per-page/per-language/per-product/per-manufacturer/per-category basis. Concept by JuxiJoza. */ $manufacturers_id = (isset($_GET['manufacturers_id'])) ? $_GET['manufacturers_id'] : ''; $tmp_products_id = (isset($_GET['products_id'])) ? (int)$_GET['products_id'] : ''; $sheets_array = array('/^' . $_SESSION['language'] . '_stylesheet/' , '/^' . $current_page_base.'/', '/^' . $_SESSION['language'] . '_' . $current_page_base .'/', '/^c_' . $current_category_id .'/', '/^' . $_SESSION['language'] . '_c_' . $current_category_id . '/', '/^m_' . $manufacturers_id.'/', '/^' . $_SESSION['language'] . '_m_' . (int)$manufacturers_id . '/', '/^p_' . $tmp_products_id . '/', '/^' . $_SESSION['language'] . '_p_' . $tmp_products_id . '/' ); while(list ($key, $value) = each($sheets_array)) { //echo "<--$value-->\n"; $directory_array = $template->get_template_part($template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css'), $value, '.css'); sort($directory_array); while(list ($key2, $value2) = each($directory_array)) { echo '<link rel="stylesheet" type="text/css" href="' . $template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css') . '/' . $value2 .'" />'."\n"; } } /** * load printer-friendly stylesheets -- named like "print*.css", alphabetically */ $directory_array = $template->get_template_part($template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css'), '/^print/', '.css'); sort($directory_array); while(list ($key, $value) = each($directory_array)) { echo '<link rel="stylesheet" type="text/css" media="print" href="' . $template->get_template_dir('.css',DIR_WS_TEMPLATE, $current_page_base,'css') . '/' . $value . '" />'."\n"; } /** * load all site-wide jscript_*.js files from includes/templates/YOURTEMPLATE/jscript, alphabetically */ $directory_array = $template->get_template_part($template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript'), '/^jscript_/', '.js'); while(list ($key, $value) = each($directory_array)) { echo '<script type="text/javascript" src="' . $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/' . $value . '"></script>'."\n"; } /** * load all page-specific jscript_*.js files from includes/modules/pages/PAGENAME, alphabetically */ $directory_array = $template->get_template_part($page_directory, '/^jscript_/', '.js'); while(list ($key, $value) = each($directory_array)) { echo '<script type="text/javascript" src="' . $page_directory . '/' . $value . '"></script>' . "\n"; } /** * load all site-wide jscript_*.php files from includes/templates/YOURTEMPLATE/jscript, alphabetically */ $directory_array = $template->get_template_part($template->get_template_dir('.php',DIR_WS_TEMPLATE, $current_page_base,'jscript'), '/^jscript_/', '.php'); while(list ($key, $value) = each($directory_array)) { /** * include content from all site-wide jscript_*.php files from includes/templates/YOURTEMPLATE/jscript, alphabetically. * These .PHP files can be manipulated by PHP when they're called, and are copied in-full to the browser page */ require($template->get_template_dir('.php',DIR_WS_TEMPLATE, $current_page_base,'jscript') . '/' . $value); echo "\n"; } /** * include content from all page-specific jscript_*.php files from includes/modules/pages/PAGENAME, alphabetically. */ $directory_array = $template->get_template_part($page_directory, '/^jscript_/'); while(list ($key, $value) = each($directory_array)) { /** * include content from all page-specific jscript_*.php files from includes/modules/pages/PAGENAME, alphabetically. * These .PHP files can be manipulated by PHP when they're called, and are copied in-full to the browser page */ require($page_directory . '/' . $value); echo "\n"; } ?> </head> <?php // NOTE: Blank line following is intended: ?>