Genius Posted June 28, 2003 Posted June 28, 2003 Does anyone know how to change the page color with a category, Please could someone help me, All i want to do is have different color schemes with each category.
Guest Posted June 29, 2003 Posted June 29, 2003 You could use your category_id as an identifier, and call a differnet stylesheet depending on that.
Genius Posted June 30, 2003 Author Posted June 30, 2003 Hi thanks for the solution, but where and how do i set the category ID with style sheet, i am new to php and still on a learning curve, thanks for your help.
mattice Posted June 30, 2003 Posted June 30, 2003 You could create a stylesheet for each category; like category 1 has 1.css, 2 has 2.css etc. Next you change ALL occurances of stylesheet.css (in each page) to a variable - $stylesheet Then in application_top.php where it checks which category it is in you set the varialbe for the stylesheet based on the category id. HTH Mattice "Politics is the art of preventing people from taking part in affairs which properly concern them"
Genius Posted June 30, 2003 Author Posted June 30, 2003 Hi , I understand the first two parts where i have to create different style sheets with different colors, the part i am not too sure is the application_top. how do i say for each catergory it must use it's style sheet.
Guest Posted June 30, 2003 Posted June 30, 2003 Hi budy, I was wondering the same thing and I'm new to this great open source program. I noticed that someone posted you some way to change your different stylesheet depending the category where you are. So I'm gonna create a little script to do that cause I think youre not a programmer :D The only thing you'll need to know is when you put your mouse over a category, youll see on the status bar of your browser for example: if your main page is DEFAULT.PHP youll see in the status bar: localhost(whatever)/default.php?cPath=31 it can be 31 or 37, whatever, youll need to check in your database the table: categories_description in this table youll see 2 columns that you need to check: categories_name, categories_id which are the name of your categories and subcategories (if you have sub categories) than the categories_id is showed in the link /default.php?cPath=31 so the variable cPath is your categories_id (gotcha :D ) Understand??? so im gonna write the little script and post it if you are interested regardssss Smaugieeee
mdfst13 Posted June 30, 2003 Posted June 30, 2003 In index.php, there is a line that looks like this: <link rel="stylesheet" type="text/css" href="stylesheet.css"> I would change that to say (all on one line; made it two lines for posting purposes) <link rel="stylesheet" type="text/css" href="stylesheet<?php echo $stylesheet_number ?>.css"> In application_top, I would change if (tep_not_null($cPath)) { $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; } else { $current_category_id = 0; } to if (tep_not_null($cPath)) { $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; $stylesheet_number = $current_category_id; } else { $current_category_id = 0; $stylesheet_number = ''; } I have not tested this, but it is how I read Mattice's suggestion. AFAIK, these are the only places where you will have to make a change. Note: behavior will be erratic if the stylesheet does not exist (i.e. if the $current_category_id is 35, you need to have a file stylesheet35.css; otherwise, your page will look weird or give an error). If need be, you could develop a more complicated way of setting the $stylesheet_number variable, but this should accomplish what you want. Hth, Matt I love deadlines. I like the whooshing sound they make as they fly by. ---Douglas Adams
Genius Posted July 1, 2003 Author Posted July 1, 2003 HI Guys, THANK YOU SO SO SO SO SO SO SO MUCH, I had followed your both instructions and yes it worked liked magic.. although i am not too sure if i did it right with sub categories as i have many sub categories i had to create a style sheet for each.. and it works, if that's the only way then cool, or if there is an easier way then even better, but your help has been great. One more question, the corners of the boxes show Grey, in all of them, i have followed the image and it sits in the images/infoboxe folder, there is only the grey corners. Is there away of me showing the different color corners or not really.. Really appreciate your guys help.. thanks Prash
Guest Posted July 1, 2003 Posted July 1, 2003 Hi budy, sure it works ;) I don't think there is a better solution. FOr the other question, I dont cath you up....?? Be more explicit....... In my case, I added in application_top.php below that part of the code (line 468) if (strlen($cPath) > 0) { $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; } else { $current_category_id = 0; } added below: if ($HTTP_GET_VARS['cPath']) { $stylesheet_number = $_GET['cPath']; $src_stylesheet = 'stylesheet'.$stylesheet_number.'.css'; } else $src_stylesheet= 'stylesheet.css'; than in my index.php page: <link rel="stylesheet" type="text/css" href="<? echo $src_stylesheet;?>"> thats it. have a great day!
Genius Posted July 1, 2003 Author Posted July 1, 2003 HI Buddy :lol: thanks so much you are great ! :wink:
Genius Posted July 1, 2003 Author Posted July 1, 2003 HI Buddy, I seem to be a bit confussed here, what i asked was Instead of me creating a style sheet for each sub category is there a way to say the the sub catergory must use it's catergory color. this is what i have in my application top (arround line 424) // calculate category path if (isset($HTTP_GET_VARS['cPath'])) { $cPath = $HTTP_GET_VARS['cPath']; } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) { $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']); } else { $cPath = ''; } if (tep_not_null($cPath)) { $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; $stylesheet_number = $current_category_id; } else { $current_category_id = 0; $stylesheet_number = ''; } if ($HTTP_GET_VARS['cPath']) { $stylesheet_number = $_GET['cPath']; $src_stylesheet = 'stylesheet'.$stylesheet_number.'.css'; } else $src_stylesheet= 'stylesheet.css'; and in my index.php <link rel="stylesheet" type="text/css" href="stylesheet<?php echo $stylesheet_number ?>.css">
Guest Posted July 1, 2003 Posted July 1, 2003 Okay, really easy to do: we just have to modify the code in application_top.php remove the code: if ($HTTP_GET_VARS['cPath']) { $stylesheet_number = $_GET['cPath']; $src_stylesheet = 'stylesheet'.$stylesheet_number.'.css'; } else $src_stylesheet= 'stylesheet.css'; ok for you replace the enterely code: if (tep_not_null($cPath)) { $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; $stylesheet_number = $current_category_id; } else { $current_category_id = 0; $stylesheet_number = ''; } by: if (strlen($cPath) > 0) { $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; $primary_category_id = $cPath_array[0]; $src_stylesheet = 'stylesheet'.$primary_category_id.'.css'; } else { $current_category_id = 0; $src_stylesheet= 'stylesheet.css'; } that's it, now your subcategory and subsub..etc...category will all have the same stylesheet as your primary category!!! I think this is the end with this subject :)
Genius Posted July 2, 2003 Author Posted July 2, 2003 HI there, I have tried what the code you mentioned, Now all i get is the same color ( the main stylesheet) through out the pages... It's not changing to the category. :cry:
Guest Posted July 2, 2003 Posted July 2, 2003 hmmm don't understand cause for me it works pretty well!! post me the part of the code that you changed (document the code, it's really important cause one day youll maybe need to modify the source code and you will get lost ;) ) or if you want, you can send me your application_top.php by mail: [email protected] Maybe you didnt create the stylesheet for each category, remember what I said about it. You need to check in database, for each main category, it has his own id (when you put your mouse over a category, youll see in the status bar of your browser cPath=72 for example, 72 represent the category id, when youll try to access to a subcategory, in the status bar for the category_id 72 (for example) his subcategory can be cPath=72_41. So remember, create each stylesheet for each category: stylesheet72.css, etc.. You put the stylesheet in the root folder: for me it's catalog/stylesheet.css, catalog/stylesheet72.css Ill hope this will help you more...
Genius Posted July 2, 2003 Author Posted July 2, 2003 Hi buddy, I have sent the application_top to you . I have the stylesheet for each category, i have stylesheet21.css, stylesheet43.css etc for each of the categories matching to the database. I have no style sheets for sub category so if i have 21_2, there is no stylesheet21_2 , Only stylesheet21. IS that right what i have so far.
Guest Posted July 2, 2003 Posted July 2, 2003 Yes you got it. You don't need to specify the stylesheet for the subcategories cause the way I modified the code, the subcategory will take the stylesheet of its parent category. I didnt receive your application_top.php yet...
Genius Posted July 2, 2003 Author Posted July 2, 2003 thanks for that, clear up :), i have sent it, i will try and send it again. ta
Guest Posted July 2, 2003 Posted July 2, 2003 I got a problem with my mail server. You can send me the code too at: [email protected] later ;)
Genius Posted July 2, 2003 Author Posted July 2, 2003 IT WORKS,... Problem was with the index page refering to the old style sheet.. :lol: Thanks a lot to smaugzone, he is a GREAT GUY!
Guest Posted July 2, 2003 Posted July 2, 2003 I'm not a great guy buddy, I just bring my knowledge as the people are doing on this forum!!! One day, ill need help too!! You can spit on that, open source is the better way to get help. Ciao
Recommended Posts
Archived
This topic is now archived and is closed to further replies.