Форумы / Cotonti / Extensions / ClassActive

A plugin to display css class based on location

tensh
#38013 22.09.2013 10:42

Hi;

I made this plugin to determine in which location the user is, and if location matches the url in navigation menu, it returns the class name "active" (or any other, can be set in settings), so that the menu item can switch colors. By now it can be achieved only by "IF" statements.

Currently it works only with URLs set to "Handy" urls (custom urls probably as well).

For nested categories, provide the Parent category in class parameters (the very first parent category in structure hierarchy) - it doesn't recognize the category depth (YET).
I hope it will work right, I made it very fast so I might not think of all alteratives.

Usage: just as you would use it with cot_url(): {PHP|classactive('module','parameters')} - e.g. {PHP|classactive('page','c=news')}.
For home page it would be {PHP|classactive('','')}.
For forums it will work only for first categories, not for subforums (by now)

Example menu link with this plugin:

<li class="{PHP|classactive('page','c=news')}"><a href="{PHP|cot_url('page', 'c=news')}">News</a></li>

Attention:
I made it to work with the plugin Slots_and_tags http://www.cotonti.com/extensions/customization-i18n/slots_n_tags - because in this plugin we cannot use IF statements and I wanted to have menu somewhere at hand.

For some reason both plugins cooperate as exected in my localhost, but fail to work on my production external server. Any help? Is it because it has memcache or something?

Link to plugin:

Classactive.zip

Отредактировано: tensh (22.09.2013 10:51, 10 лет назад)