mycalendar: no output at all when no

Creating and modifying plugins.
Post Reply
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

mycalendar: no output at all when no

Post by stm999999999 »

hello,

we have some sidebar plugins like history (posts before 6 months) and so, which do not appear as an empty plugin (title plus space) when there are no output-items, but they do not appear in the sidebar at all.

Can the mycalendar plugin work the same way? Or can somebody make the plugin to do so?
Ciao, Stephan
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I just looked at the internal archive plugin, and there's nothing special in it. If you direct me to the plugin that hides itself, I'll have a closer look at it and see what can be done with other plugins.
Judebert
---
Website | Wishlist | PayPal
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

it is serendipity_plugin_history
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

A plugin will not return anything if the "generate_content()" returns "false" instead of echoing output, AFAIR...

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/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

OK, I found it.

I make a change to the plugin:

Code: Select all

$propbag->add('configuration', array('title', 'items', 'datefm', 'datefm2', 'showtime', 'autoprune', 'countdown', 'skipfirst', 'showempty'));

...

            case 'showempty':
                $propbag->add('type',        'boolean');
                $propbag->add('name',        PLUGIN_MYCALENDAR_SIDE_SHOWEMPTY);
                $propbag->add('description', '');
                $propbag->add('default',     true);
                break;

...

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

        $showempty = serendipity_db_bool($this->get_config('showempty', true));

...

        $items = serendipity_db_query("SELECT * from {$serendipity['dbPrefix']}mycalendar " . $filter . " ORDER BY eventdate LIMIT " . $this->get_config('items', 5));
        if (!is_array($items)) {
			if ($showempty) {
	            return true;
	        } else {
	        	return false;
	        }
        }
for the lang-files:

Code: Select all

@define('PLUGIN_MYCALENDAR_SIDE_SHOWEMPTY', 'Show plugin when no events?');      

@define('PLUGIN_MYCALENDAR_SIDE_SHOWEMPTY', 'Anzeigen auch wenn kein Termin vorhanden?');       
I think, this can be a good idea for every sidebar-plugin: to give the user the choice whether he wants empty plugins or not. comments?
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Seems like a very good suggesiton! Maybe you want to get yourself accustomed with the "patch / diff" utils so I can submit your patch easily? :)

Best 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/
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I love the idea, and the implementation looks simple. The only problem I see at the moment is that each plugin has to be modified separately.

But adding a global configuration item just seems too difficult.
Judebert
---
Website | Wishlist | PayPal
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

The only problem I see at the moment is that each plugin has to be modified separately.
yes, I think so.
But adding a global configuration item just seems too difficult.
I don't know if it would be a good idea to make it a global thing: Perhaps someone wants to show some sidebar item even if it is empty and another not.
Ciao, Stephan
Post Reply