Easier way to use parent as class for sections

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Easier way to use parent as class for sections

Post by Dr.CSS »

I have a need in some sites to set the style for certain pages and their children, like sections, everything under this parent including the parent should look like this etc...

I have always used a UDT which means I had to remember it or I had to bookmark a thread/post here that has them, well NO more...

class='a{$friendly_position|truncate:1:"" == ""}'   will give you the top menu items number from it's position in the menu and all of it's children get the same number, instead of a2.1 or a2.1.1 it will be class='a2'...

NOTE: The a is needed because you can't use numbers for class or ID, speaking of which this could be...

id='a{$friendly_position|truncate:1:"" == ""}'

Just make sure if it's an ID it's only used once in a template...
Post Reply

Return to “Tips and Tricks”