Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Load CSS if parent cpath = x

    Is it possible to write a php query to check if a product or category page derives from a certain category, and if so, load a different css or image.

    So

    Cat 1 ----> Cat 6 ----> Cat 11 ----> Product 2

    That would do nothing but

    Cat 4 ----> Cat 8 ----> Cat 13 ----> Product 5

    Loading any of category or product deriving from cat 4 would load a file in the if argument.

    Any ideas?

    The reason being, I would like to load a different header image for a particular group of categories or products.

  2. #2
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,021
    Plugin Contributions
    3

    Default Re: Load CSS if parent cpath = x

    Someone already has. Check the readme file in includes/templates/classic/css.

  3. #3
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: Load CSS if parent cpath = x

    Unless I'm reading that wrong, I would have to put each category or product in manually?

  4. #4
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,021
    Plugin Contributions
    3

    Default Re: Load CSS if parent cpath = x

    In your example, the stylesheet named c_4.css would apply to all pages that derived from the category with an id of 4. You would have to create the stylesheets manually. Could be I misunderstood your question.

  5. #5
    Join Date
    Mar 2009
    Posts
    609
    Plugin Contributions
    0

    Default Re: Load CSS if parent cpath = x

    c_4.css only modifies category 4

    Any categories below category 4 I would then have to create a new css file for, that wouldn't work for me.

  6. #6
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,378
    Plugin Contributions
    0

    Default Re: Load CSS if parent cpath = x

    How many categories do you have for each custom stylesheet? And how many different category specific stylesheets do you anticipate needing?

    I suppose it would be possible to "trick" ZC into loading the same css file for multiple categories by using a bit of php to call for the same category specific stylesheet. Something like (in pseudo-code)...

    if I'm in category 1,2,3,4,5 or 6
    then use stylesheet c_1.css
    else if I'm in category 7,8,9,10
    then use stylesheet c_2.css
    end if

    But that seems a lot of work for something so simple. If you have, say, 10 categories that each use one stylesheet, and 10 others that each use a different stylesheet, then you simply create those 2 stylesheets and make 9 copies of each of them, each with its appropriate name. After all, you're not duplicating everything that is in the main stylesheet.css file. You're just putting styles in the category specific stylesheets which need to be different for those categories. So having a bunch of copies of these relatively small files around doesn't slow things down or hog resources.

    Rob

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

    Default Re: Load CSS if parent cpath = x

    Improved Stylesheet Calls can cover all of a top category's subcats with one stylesheet. You can then have another stylesheet for just one of its subcats if you want.
    You can apply an additional stylesheet for each ez-page chapter, covering all of its pages.
    You can apply an additional stylesheet for each ez-page.
    You can apply an additional stylesheet for each top category, covering all of its subcats.

 

 

Similar Threads

  1. v151 Linked product - how to change the relative/parent cPath ?
    By twitchtoo in forum General Questions
    Replies: 0
    Last Post: 9 Feb 2014, 05:18 PM
  2. CSS load
    By Lopi in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 24 Jun 2011, 10:53 AM
  3. Load CSS In Product Listing Module
    By CoolCarPartsOnline in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 24 Feb 2010, 01:10 PM
  4. HELP ! Clicking Parent Catogory does not load it's page !
    By newfu in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 1 May 2009, 02:48 PM
  5. CSS problems - Stylesheet won't load
    By johnbtes in forum Templates, Stylesheets, Page Layout
    Replies: 28
    Last Post: 6 Apr 2008, 05:08 AM

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