Individual colors for each page - a smarty problem
Posted: Fri Dec 30, 2011 12:49 pm
Hi there!
I'm currently struggeling with my homepage and my design ideas. First of all: I did my best to use google and the web to find an answer, because i can't imagine I'm the only one who has problems implementing such behaviour. However, i did not find an answer, that's why i ask here.
Now my problem is the following: I want my page to be seperated into different kind-of "categories". Each first-level menu element shall create a new "category" for its child elements. On my webpage, each category shall have another color that appears in several ways (headlines, navigation buttons, links and so on shall have the category's color).
An example: So imagine the page "home" in blue color. And imagine a page "photographs" in red color. All child pages of these two shall be in the same color as their first-level-parent. So: "home > news" shall also be blue, "photographs > nature" and "photographs > portraits" shall both be red.
(I hope you can understand my idea - if not please ask me)
What i want to achieve: I need an option in the backend that allows me to apply a color to each first-level-page. All sub-pages should simply inherit the color, without additional editing in the backend. Thus it's easy to add a new "category" to my website.
There is the well-knows but pretty unflexible way with css-classes.
I could create a separate class for each category in my css-stylesheet. Then i would need to add the matching class somewhere in my template.
Problem: very unfelxible. Once I define a new first-level-page (thus defining a new category with it's own color) i also need to make several defines in my stylesheet.
This is very unhandy.
So I tried it with Smarty (which is a great thing in general!). However, here is where the problems begin: I somehow need to add some extra data to each first-level-page to specify the color for all the child elements. And then, in the template i need to find out, which color i need to show (which color the first-level-parent of the page has attached).
I really don't know, what to do here.
Do you have an idea? Thanks for any support,
Bääääär
PS: I tried to specify a color for each page using the "smarty-field" in the options tab of my pages. I wrote something like this in there: {assign var="pagecolor" value="#eca610"}
This way i can define a color for each page (still not the category-behaviour but at least a good point to start). However, when i insert this smarty-variable into my stylesheet, it won't work - the stylesheet is chached and won't update every time, i load a page.
I'm currently struggeling with my homepage and my design ideas. First of all: I did my best to use google and the web to find an answer, because i can't imagine I'm the only one who has problems implementing such behaviour. However, i did not find an answer, that's why i ask here.
Now my problem is the following: I want my page to be seperated into different kind-of "categories". Each first-level menu element shall create a new "category" for its child elements. On my webpage, each category shall have another color that appears in several ways (headlines, navigation buttons, links and so on shall have the category's color).
An example: So imagine the page "home" in blue color. And imagine a page "photographs" in red color. All child pages of these two shall be in the same color as their first-level-parent. So: "home > news" shall also be blue, "photographs > nature" and "photographs > portraits" shall both be red.
(I hope you can understand my idea - if not please ask me)
What i want to achieve: I need an option in the backend that allows me to apply a color to each first-level-page. All sub-pages should simply inherit the color, without additional editing in the backend. Thus it's easy to add a new "category" to my website.
There is the well-knows but pretty unflexible way with css-classes.
I could create a separate class for each category in my css-stylesheet. Then i would need to add the matching class somewhere in my template.
Problem: very unfelxible. Once I define a new first-level-page (thus defining a new category with it's own color) i also need to make several defines in my stylesheet.
This is very unhandy.
So I tried it with Smarty (which is a great thing in general!). However, here is where the problems begin: I somehow need to add some extra data to each first-level-page to specify the color for all the child elements. And then, in the template i need to find out, which color i need to show (which color the first-level-parent of the page has attached).
I really don't know, what to do here.
Do you have an idea? Thanks for any support,
Bääääär
PS: I tried to specify a color for each page using the "smarty-field" in the options tab of my pages. I wrote something like this in there: {assign var="pagecolor" value="#eca610"}
This way i can define a color for each page (still not the category-behaviour but at least a good point to start). However, when i insert this smarty-variable into my stylesheet, it won't work - the stylesheet is chached and won't update every time, i load a page.