Show element only in a certain category

Discussion corner for Developers of Serendipity.
Post Reply
User avatar
Posts: 77
Joined: Fri Mar 16, 2007 9:10 pm
Location: Flensburg / Germany

Show element only in a certain category

Post by rowi » Mon Jul 23, 2012 11:31 am


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?

User avatar
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany

Re: Show element only in a certain category

Post by garvinhicking » Mon Jul 23, 2012 12:50 pm


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.

# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy:
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby:

Post Reply