Recent Entries Plugin - show on all, extended, or overview

Creating and modifying plugins.
Post Reply
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Recent Entries Plugin - show on all, extended, or overview

Post by Don Chambers »

I patched my copy of the recent entries plugin to provide the same functionality that other plugins have, which is the ability to display at all times, only on the overview page, or only on extended view pages.

Any objection to me committing this revision to 1.3?
=Don=
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Recent Entries Plugin - show on all, extended, or overvi

Post by garvinhicking »

Hi!

Showing your patch woudl've been nice, but feel free to commit this to 1.3 :)

(Please also document in your docs/NEWS file)

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/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post by Don Chambers »

Code: Select all

         $propbag->add('name',          PLUGIN_RECENTENTRIES_TITLE);
         $propbag->add('description',   PLUGIN_RECENTENTRIES_BLAHBLAH);
         $propbag->add('stackable',     true);
-        $propbag->add('author',        'Christian Machmeier, Christian Brabandt, Judebert');
-        $propbag->add('version',       '1.9');
+        $propbag->add('author',        'Christian Machmeier, Christian Brabandt, Judebert, Don Chambers');
+        $propbag->add('version',       '2.0');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
             'php'         => '4.1.0'
         ));
-        $propbag->add('configuration', array('title', 'number', 'number_from', 'dateformat', 'category', 'randomize'));
+        $propbag->add('configuration', array('title', 'number', 'number_from', 'dateformat', 'category', 'randomize', 'show_where'));
         $propbag->add('groups', array('FRONTEND_VIEWS'));
     }
 
@@ -108,6 +108,15 @@
                 $propbag->add('default',       'none');
                 break;
 
+            case 'show_where':
+                $select = array('extended' => PLUGIN_ITEM_DISPLAY_EXTENDED, 'overview' => PLUGIN_ITEM_DISPLAY_OVERVIEW, 'both' => PLUGIN_ITEM_DISPLAY_BOTH);
+                $propbag->add('type',        'select');
+                $propbag->add('select_values', $select);
+                $propbag->add('name',        PLUGIN_ITEM_DISPLAY);
+                $propbag->add('description', '');
+                $propbag->add('default',     'both');
+            break;
+                
             default:
                 return false;
         }
@@ -120,7 +129,14 @@
         $number         = $this->get_config('number');
         $dateformat     = $this->get_config('dateformat');
         $category       = $this->get_config('category', 'none');
-        
+        $show_where = $this->get_config('show_where', 'both');
+
+        if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) {
+            return false;
+        } else if ($show_where == 'overview' && isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) {
+            return false;
+        }
+
=Don=
Post Reply