Landho Posted February 11, 2009 Share Posted February 11, 2009 I've been trying to figure out an approrpiate way to setup a CSS style that controlled the color scheme of each category... Using the category id, and creating a style with that ID and the parameters... sounds pretty simple, but has been daunting me. Looking for pretty basic stuff - just the row for the product name in product_info.php Maybe will try to format the menu in the future - but for now just shooting for the basic look on the product_info.php page. Anyone have any tips or contributions which may provide this ability? Link to comment Share on other sites More sharing options...
Hotclutch Posted February 11, 2009 Share Posted February 11, 2009 I've been trying to figure out an approrpiate way to setup a CSS style that controlled the color scheme of each category... Using the category id, and creating a style with that ID and the parameters... sounds pretty simple, but has been daunting me. Looking for pretty basic stuff - just the row for the product name in product_info.php Maybe will try to format the menu in the future - but for now just shooting for the basic look on the product_info.php page. Anyone have any tips or contributions which may provide this ability? If I am not mistaken, Product name and Price in product_info.php are controlled by the PageHeading Class in your CSS. Link to comment Share on other sites More sharing options...
Landho Posted February 13, 2009 Author Share Posted February 13, 2009 Thanks... I am trying to work this out... will share if I get something going. Link to comment Share on other sites More sharing options...
lastblackjellybean Posted February 13, 2009 Share Posted February 13, 2009 I'm not the best with this stuff but I'm working on this at the minute...its not elegant but it works. <link rel="stylesheet" type="text/css" href="stylesheet.css" /> <?php if (isset($_GET['cPath'])) { $catno= explode("_", $_GET['cPath']); $catno= $catno[0]; echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet".$catno.".css\" />\n"; }?> First part loads the original stylesheet, with default colours etc for index page, information etc Second gets the category id then writes a second stylesheet call. The second stylesheet contains only the changes to the original for a particular category (mine is only 4 lines) You'll need one for each category in the form of stylesheet1.css, stylesheet2.css etc....whatever your cat numbers are ...i wholeheartedly welcome better solutions Link to comment Share on other sites More sharing options...
burt Posted February 13, 2009 Share Posted February 13, 2009 <link rel="stylesheet" type="text/css" href="stylesheet.css" /> <?php if (isset($current_category_id)) echo '<link rel="stylesheet" type="text/css" href="stylesheet', $current_category_id, '.css" />'; ?> Off the top of my head so might not work. But $current_category_id gets the ID of the current category you are looking at... Link to comment Share on other sites More sharing options...
lastblackjellybean Posted February 13, 2009 Share Posted February 13, 2009 works like a charm. much better :) Link to comment Share on other sites More sharing options...
lastblackjellybean Posted February 13, 2009 Share Posted February 13, 2009 actually, when viewing an individual product within a category, this doesn't work. rats. Link to comment Share on other sites More sharing options...
burt Posted February 13, 2009 Share Posted February 13, 2009 It should work on the product_info.php page... Link to comment Share on other sites More sharing options...
lastblackjellybean Posted February 13, 2009 Share Posted February 13, 2009 my mistake, its working as expected, its just that for my setup, i want the subcategories to have the same style as their parents, so havent got any sub cat stylesheets set up. Link to comment Share on other sites More sharing options...
burt Posted February 13, 2009 Share Posted February 13, 2009 use a switch to control the stylesheet per current_category_id uk.php.net/switch Alternatively, just grab the parent_id of the current_category_id and display that. I'll leave you to work that one out ;) Link to comment Share on other sites More sharing options...
lastblackjellybean Posted February 13, 2009 Share Posted February 13, 2009 Right, but for my usage of all subcats and products being the same style as the parents, wouldn't my original code be easier, otherwise a new line would need to be added to the switch every time a subcategory was added? Or is there a flaw/problem with my original code? Cheers for the help Link to comment Share on other sites More sharing options...
burt Posted February 14, 2009 Share Posted February 14, 2009 If you had a 3rd level of subcats; 1_12_23 or whatever, should 23 take the style of 12 or 1 ? Link to comment Share on other sites More sharing options...
lastblackjellybean Posted February 16, 2009 Share Posted February 16, 2009 23 would take the style of 1 ideally Link to comment Share on other sites More sharing options...
burt Posted February 16, 2009 Share Posted February 16, 2009 $cPath_array['0'] Link to comment Share on other sites More sharing options...
lastblackjellybean Posted February 16, 2009 Share Posted February 16, 2009 cheers burt. much obliged Link to comment Share on other sites More sharing options...
burt Posted February 16, 2009 Share Posted February 16, 2009 echo sizeof($cPath_array) > 1 ? $cPath_array[sizeof($cPath_array)-2] : $cPath_array['0']; __should__ (ntested though!) get the parent_id of the current_category_id. Dunno if useful for anything? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.