Page 1 of 1
mycalendar: no output at all when no
Posted: Mon Oct 30, 2006 9:30 pm
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?
Posted: Thu Nov 02, 2006 9:39 pm
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.
Posted: Fri Nov 03, 2006 12:45 am
by stm999999999
it is serendipity_plugin_history
Posted: Fri Nov 03, 2006 11:50 am
by garvinhicking
Hi!
A plugin will not return anything if the "generate_content()" returns "false" instead of echoing output, AFAIR...
HTH,
Garvin
Posted: Fri Nov 03, 2006 11:48 pm
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?
Posted: Sun Nov 05, 2006 12:48 pm
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
Posted: Tue Nov 07, 2006 10:14 pm
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.
Posted: Wed Nov 08, 2006 1:07 am
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.