The Serendipity Handbook

You can now read the (german) handbook here: PDF - https://github.com/s9y/Book (LaTeX source).

Forum-Information

Before posting about errors, make sure that the answer cannot already be found in our FAQ or by searching this forum!
Posting is restricted to registered users (registering is free and simple!) due to recent spam attacks. When having trouble with this board, contact garvin(-at)s9y(-dot)org.

Board index Development Show element only in a certain category

Discussion corner for Developers of Serendipity.
User avatar
rowi
Regular
 
Posts: 56
Joined: Fri Mar 16, 2007 10:10 pm
Location: Flensburg / Germany

Postby rowi » Mon Jul 23, 2012 11:31 am

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?

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

Postby garvinhicking » Mon Jul 23, 2012 12:50 pm

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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/



Return to Development

Who is online

Users browsing this forum: No registered users and 2 guests