Hiding Sidebar Plugins

Creating and modifying plugins.
Post Reply
User avatar
RobA
Regular
Posts: 317
Joined: Wed Apr 27, 2005 5:11 pm
Contact:

Hiding Sidebar Plugins

Post by RobA » Tue May 10, 2005 6:58 pm

Is there a way to flag a sidebar plugin so it only displays when a user is logged in?

-Rob A>

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

Re: Hiding Sidebar Plugins

Post by garvinhicking » Tue May 10, 2005 9:00 pm

There is currently no way.

You could modify the "sidebarhider" plugin to fold in some specific sidebars. You could also enhance the plugin to automatically hide some plugins only for not logged in users.

To completely hide a plugin (not only via JavaScript) would mean you'd need to modify the plugin itself you want to not display.

Inside the generate_content() method of a sidebar plugion you can do a check:

Code: Select all

function generate_content(&$title) {
global $serendipity;

  if (!$_SESSION['serendipityAuthedUser']) {
    return false;
  }

  // more code here
}


HTH,
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/

User avatar
RobA
Regular
Posts: 317
Joined: Wed Apr 27, 2005 5:11 pm
Contact:

Post by RobA » Wed May 11, 2005 4:04 pm

Brilliant!
Thanks!

I have munged up my copy of plugin_internal.inc.php so the serendipity_html_nugget_plugin now gives me an extra configuration parameter "Hidden for Guests?".

Image

I went and hard coded the strings in english as I didn't want to dig to find where all the language constants were stored.

This is awkward to have to add to every type of sidebar plugin code. Additionally, it puts my code out of sync with the source :(

Could this be done at the plugin admin level? I.E. be a parameter (like the LEFT/RIGHT display selection) that can just be toggled in the plugin admin screen. Or would that be way too complicated?

Thanks for the code snippit!

-Rob A>

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

Post by garvinhicking » Wed May 11, 2005 4:08 pm

Actually I have not yet come up with an idea that would make this function appear in all plugins, because as you mention it would mean to have a new column.

I will further ponder about it and hope to come to a solution :)

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/

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

Post by garvinhicking » Thu May 12, 2005 4:29 pm

I have just committed a simple plugin API hook into the 0.9 core. You can patch it easily in your 0.8 CVS:

http://svn.berlios.de/viewcvs/serendipi ... r1=7&r2=93

And then I've committed the hiding functionality into the sidebar hider plugin. How's that? :)

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/

Post Reply