Guest Posted February 28, 2009 Posted February 28, 2009 I'm not sure if there's a contribution out there that will do this. Someone I know has asked me to build them a site, and they're wanting the basic color scheme to change depending on what top level category they are in. Using a basic example - electronics would have grey boxes, furniture would have green, etc. The majority of the changes they'd like would all be managed within the stylesheet...but is there a contribution out there that would allow me to specify a stylesheet based on category name or id or rank or something?
germ Posted February 28, 2009 Posted February 28, 2009 In the <head> section of the osC pages this code: <link rel="stylesheet" type="text/css" href="stylesheet.css"> Could be replaced with something like: <?php switch ( $cPath ) { case '1': echo '<link rel="stylesheet" type="text/css" href="stylesheet1.css">'; break; case '2': echo '<link rel="stylesheet" type="text/css" href="stylesheet2.css">'; break; default: echo '<link rel="stylesheet" type="text/css" href="stylesheet.css">'; } ?> Of course you'd use your own stylesheet names, and your own category id's, but you probably get the picture. The problem with this is it's not "automatic". Meaning if they want to add a new cateory/stylsheet in the future it requires manual updates to the code. :blush: And if you were actually going to do something like this, you'd want to put the stylesheet changing code in it's own PHP file and in all the osC pages put something like this in the <head> section in place of the stylesheet designator: <?php require('stylesheet.php'); ?> That way you just have to edit one file and it affects all the pages. This is only one possible solution. When it comes to coding there's usually not just one way to accomplish a task. If anyone else has something they'd like to add - post away! I aint the "sharpest tool in the shed" by no stretch of anyone's imagination! :lol: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
yakbuttertea Posted March 1, 2009 Posted March 1, 2009 In the <head> section of the osC pages this code: <link rel="stylesheet" type="text/css" href="stylesheet.css"> Could be replaced with something like: <?php switch ( $cPath ) { case '1': echo '<link rel="stylesheet" type="text/css" href="stylesheet1.css">'; break; case '2': echo '<link rel="stylesheet" type="text/css" href="stylesheet2.css">'; break; default: echo '<link rel="stylesheet" type="text/css" href="stylesheet.css">'; } ?> Of course you'd use your own stylesheet names, and your own category id's, but you probably get the picture. The problem with this is it's not "automatic". Meaning if they want to add a new cateory/stylsheet in the future it requires manual updates to the code. :blush: And if you were actually going to do something like this, you'd want to put the stylesheet changing code in it's own PHP file and in all the osC pages put something like this in the <head> section in place of the stylesheet designator: <?php require('stylesheet.php'); ?> That way you just have to edit one file and it affects all the pages. This is only one possible solution. When it comes to coding there's usually not just one way to accomplish a task. If anyone else has something they'd like to add - post away! I aint the "sharpest tool in the shed" by no stretch of anyone's imagination! :lol: In the same kind of idea, how can we have products listings appear different depending on the categories? I am doing a site for selling bulk herbs, I would like to sort the product listing/catalog following the Common names or the Botanical Names. I was thinking doing 2 categories one Botanical and one Common and do the product listing differently but I have no idea on how to do that. If someone can enlighten me it would be great. Thanks, Fred
Recommended Posts
Archived
This topic is now archived and is closed to further replies.