Forums / Templates, Stylesheets, Page Layout / subcategories not getting parent category stylesheet

subcategories not getting parent category stylesheet

Locked

Started by fostergross on 30 Jan 2007, 6:59 PM · Views: 3,340

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
30 Jan 2007, 6:59 PM
#1
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

subcategories not getting parent category stylesheet

I've read through the css_readme and searched through the forums but I couldn't find an answer for my problem.

I have a site I'm developing and each primary category needs it own colour system. Each subcategory in the primary category also needs to inherit this colour system. However, I can't figure out a way (I haven't tried getting messy with the php yet) to make all the subcategories use the parent category's stylesheet.

for example: c_65 is a parent category, it has c_65_66, c_65_67, and c_65_68 as children. I'm trying to avoid creating a stylesheet for each subcategory, as that creates maintainance issue, and instead have c_65.css apply to the subcategories that c_65 contains.

So is there anyway to do this? I don't mind getting into the php if that needs to be done.

30 Jan 2007, 10:07 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: subcategories not getting parent category stylesheet

While I have not double checked this for you - I believe that if you designate a style sheet for a category then it will also be utilized for it's children or subs also

so have one for the cat c _65, another for a different cat say c_77, etc

Zen-Venom Get Bitten

30 Jan 2007, 10:56 PM
#3
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

Re: subcategories not getting parent category stylesheet

Thanks for replying so fast kobra. But on my install of 1.3.7 when I go into "index.php?main_page=index&cPath=65_69". The stylesheet c_65.css is not loaded. Also if I target a sub category, it doesn't load in the parent. So should I start poking in the css loader php file.

thanks again.

30 Jan 2007, 11:13 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: subcategories not getting parent category stylesheet

I must have missed something....Have you looked at the readme in the /css directory?

Zen-Venom Get Bitten

31 Jan 2007, 2:27 PM
#5
drbyte avatar

drbyte

Sensei

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

Re: subcategories not getting parent category stylesheet

At the present time, it pulls for the current category, not for a parent.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

31 Jan 2007, 6:04 PM
#6
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

Re: subcategories not getting parent category stylesheet

So in the current build there is no standard way to do what I'm attempting to accomplish? If I get any decent results from poking around in the CSS loader files I'll post it here.

6 Feb 2007, 4:05 PM
#7
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

Re: subcategories not getting parent category stylesheet

Allright, I figured it out, and it was quite easy.

In the your_template/common/html_header.php around line 53 an array is created that stores the values of the stylesheet names that will be loaded, here is where we will add a new value for our root category stylesheet.

First, above the array you have to create a new variable that will store the value of the root category.

$top_category =  substr($cPath, 0, strpos($cPath, '_'));

Then in the array mentioned before ($sheets_array) needs to be modified to look like the following

 $sheets_array = array('/' . $_SESSION['language'] . '_stylesheet', 
                        '/' . $tmp_pagename,  
                        '/' . $_SESSION['language'] . '_' . $tmp_pagename,
                        '/c_' . $top_category, //my top category search.
			'/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 
                        );

The modified line is the fourth node in the array. It simply makes a node in the array that reflects the current top level category.

So there you have it, an easy way to load both primary category style sheets and sub-category sheets if you need them.

6 Feb 2007, 4:10 PM
#8
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: subcategories not getting parent category stylesheet

And this is what is great about OpenSource Projects

Zen-Venom Get Bitten

7 Feb 2007, 2:40 PM
#9
fostergross avatar

fostergross

New Zenner

Join Date:
Dec 2006
Posts:
20
Plugin Contributions:
0

Re: subcategories not getting parent category stylesheet

It certainly is. I'm really impressed with the quality of zen cart and hope that I can contribute more. If I come up with anything else I think others can use, I'll be sure to post it here (not this thread, but in the forums :) )

15 Feb 2007, 2:41 AM
#10
clydejones avatar

clydejones

Deceased

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

Re: subcategories not getting parent category stylesheet

I've tried out your modification and it works really well - no more multiple c_??_?? stylesheets.

Congrats.

NOTE: We are sorry that Clyde is no longer with us.
We are grateful for all his contributions to the Zen Cart community.