Page 1 of 1

Show element only in a certain category

Posted: Mon Jul 23, 2012 11:31 am
by rowi
Hi,

I try to show an element only within articles of a certain category (and the category itself). Is there an easy way to determine the category and to show either a whole Sidebar-Plugin or div element based on the category?
I suppose a sidebar plugin can't decide for itself whether it's been shown so I guess the div Element is the way to go?

Re: Show element only in a certain category

Posted: Mon Jul 23, 2012 12:50 pm
by garvinhicking
Hi!

Yes, you can check if $serendipity['GET']['category'] is empty or not; this holds the ID of the category that you are viewing (if you are viewing) if you custom-code a plugin.

You might need the categorytemplates event plugin in conjunction, so that it can set this variable when you are viewing a single entry that is only in one category (by default s9y has no "category-specific" single-entry view, it only knows a single-entry, not single-entry-within-category-X).

The serendipity_event_sidebarhider plugin might also be something you should look into.

Regards,
Garvin