Page 1 of 1

category_plugin: hide frontpage link

Posted: Fri Jan 30, 2009 12:33 pm
by onli
That's about the frontpage link shown above the list of all categories. I added an option to disable this link because it's redundant on my configuration (click on the banner leads to the frontpage which contains all categories). Maybe you want to add something like this, diff is against the snapshot from yesterday (s9y_200901292342.tar.gz ).

Code: Select all

--- plugin_internal.inc.php	2009-01-30 12:05:30.000000000 +0100
+++ /var/www/include/plugin_internal.inc.php	2009-01-30 12:06:57.000000000 +0100
@@ -1430,7 +1430,7 @@
         $propbag->add('stackable',     true);
         $propbag->add('author',        'Serendipity Team');
         $propbag->add('version',       '2.03');
-        $propbag->add('configuration', array('title', 'authorid', 'parent_base', 'hide_parent', 'image', 'sort_order', 'sort_method', 'allow_select', 'hide_parallel', 'show_count', 'smarty'));
+        $propbag->add('configuration', array('title', 'authorid', 'parent_base', 'hide_parent', 'image', 'sort_order', 'sort_method', 'allow_select', 'hide_parallel', 'show_count', 'show_all', 'smarty'));
         $propbag->add('groups',        array('FRONTEND_VIEWS'));
     }
 
@@ -1545,6 +1545,13 @@
                 $propbag->add('default',     false);
                 break;
 
+            case 'show_all':
+                $propbag->add('type',        'boolean');
+                $propbag->add('name',        CATEGORY_PLUGIN_SHOWALL);
+                $propbag->add('description', '');
+                $propbag->add('default',     true);
+                break;
+
             default:
                 return false;
         }
@@ -1615,6 +1622,8 @@
         $hide_parallel = serendipity_db_bool($this->get_config('hide_parallel'));
         $hidedepth     = 0;
 
+        $show_all_link = $this->get_config('show_all');
+
         if (is_array($categories) && count($categories)) {
             $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
             foreach ($categories as $cid => $cat) {
@@ -1695,13 +1704,17 @@
         }
 
         if (!$smarty) {
-            $html .= sprintf(
-                '<div class="category_link_all"><br /><a href="%s" title="%s">%s</a></div>',
-
-                $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?frontpage',
-                ALL_CATEGORIES,
-                ALL_CATEGORIES
-            );
+            if ($show_all_link) {
+                $html .= sprintf(
+                    '<div class="category_link_all"><br /><a href="%s" title="%s">%s</a></div>',
+
+                    $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?frontpage',
+                    ALL_CATEGORIES,
+                    ALL_CATEGORIES
+                    );
+                } else {
+                    $html .= '<br />';
+                }
         }
 
         if (!$smarty && $is_form) {

--- serendipity_lang_en.inc.php	2009-01-30 12:15:58.000000000 +0100
+++ /var/www/lang/serendipity_lang_en.inc.php	2009-01-30 12:08:59.000000000 +0100
@@ -807,6 +807,7 @@
 @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?');
 @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.');
 @define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?');
+@define('CATEGORY_PLUGIN_SHOWALL', 'Show link to content of all categories?');
 @define('AUTHORS_SHOW_ARTICLE_COUNT', 'Show number of articles next to author name?');
 @define('AUTHORS_SHOW_ARTICLE_COUNT_DESC', 'If this option is enabled, the number of articles by this author is shown next to the authors name in parentheses.');
 @define('CUSTOM_ADMIN_INTERFACE', 'Custom admin interface available');

--- serendipity_lang_de.inc.php	2009-01-30 12:16:17.000000000 +0100
+++ /var/www/lang/serendipity_lang_de.inc.php	2009-01-30 12:09:56.000000000 +0100
@@ -809,6 +809,7 @@
 @define('CATEGORY_PLUGIN_TEMPLATE', 'Smarty-Templating aktivieren?');
 @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'Falls diese Option aktiviert ist, wird das Kategorie-Plugin die Liste mittels Smarty-Templates ausgeben. Durch die Aktivierung der Option kann dann das Layout mittels der Template-Datei "plugin_categories.tpl" angepasst werden. Die Aktivierung dieser Option bringt Performance-Einbußen mit sich, daher sollten Sie die Option nur dann aktivieren, wenn Ihnen die Anpassungen wichtig sind.');
 @define('CATEGORY_PLUGIN_SHOWCOUNT', 'Anzahl der Einträge pro Kategorie anzeigen?');
+@define('CATEGORY_PLUGIN_SHOWALL', 'Link zum Inhalt aller Kategorien anzeigen?');
 @define('AUTHORS_SHOW_ARTICLE_COUNT', 'Anzahl der Artikel neben dem Autor-Namen anzeigen? ');
 @define('AUTHORS_SHOW_ARTICLE_COUNT_DESC', 'Wenn diese Option aktiviert ist, wird die Anzahl der von diesem Autor verfassten Artikel in Klammern neben seinem Namen angezeigt.');
 @define('CUSTOM_ADMIN_INTERFACE', 'Angepasste Admin-Oberfläche vorhanden');

--- serendipity_lang_en.inc.php-utf8	2009-01-30 12:15:50.000000000 +0100
+++ /var/www/lang/UTF-8/serendipity_lang_en.inc.php	2009-01-30 12:09:11.000000000 +0100
@@ -807,6 +807,7 @@
 @define('CATEGORY_PLUGIN_TEMPLATE', 'Enable Smarty-Templates?');
 @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'If this option is enabled, the plugin will utilize Smarty-Templating features to output the category listing. If you enable this, you can change the layout via the "plugin_categories.tpl" template file. Enabling this option will impact performance, so if you do not need to make customizations, leave it disabled.');
 @define('CATEGORY_PLUGIN_SHOWCOUNT', 'Show number of entries per category?');
+@define('CATEGORY_PLUGIN_SHOWALL', 'Show link to content of all categories?');
 @define('AUTHORS_SHOW_ARTICLE_COUNT', 'Show number of articles next to author name?');
 @define('AUTHORS_SHOW_ARTICLE_COUNT_DESC', 'If this option is enabled, the number of articles by this author is shown next to the authors name in parentheses.');
 @define('CUSTOM_ADMIN_INTERFACE', 'Custom admin interface available');

--- serendipity_lang_de.inc.php-utf8	2009-01-30 12:16:06.000000000 +0100
+++ /var/www/lang/UTF-8/serendipity_lang_de.inc.php	2009-01-30 12:10:33.000000000 +0100
@@ -809,6 +809,7 @@
 @define('CATEGORY_PLUGIN_TEMPLATE', 'Smarty-Templating aktivieren?');
 @define('CATEGORY_PLUGIN_TEMPLATE_DESC', 'Falls diese Option aktiviert ist, wird das Kategorie-Plugin die Liste mittels Smarty-Templates ausgeben. Durch die Aktivierung der Option kann dann das Layout mittels der Template-Datei "plugin_categories.tpl" angepasst werden. Die Aktivierung dieser Option bringt Performance-Einbußen mit sich, daher sollten Sie die Option nur dann aktivieren, wenn Ihnen die Anpassungen wichtig sind.');
 @define('CATEGORY_PLUGIN_SHOWCOUNT', 'Anzahl der Einträge pro Kategorie anzeigen?');
+@define('CATEGORY_PLUGIN_SHOWALL', 'Link zum Inhalt aller Kategorien anzeigen?');
 @define('AUTHORS_SHOW_ARTICLE_COUNT', 'Anzahl der Artikel neben dem Autor-Namen anzeigen? ');
 @define('AUTHORS_SHOW_ARTICLE_COUNT_DESC', 'Wenn diese Option aktiviert ist, wird die Anzahl der von diesem Autor verfassten Artikel in Klammern neben seinem Namen angezeigt.');
 @define('CUSTOM_ADMIN_INTERFACE', 'Angepasste Admin-Oberfläche vorhanden');

Re: category_plugin: hide frontpage link

Posted: Fri Jan 30, 2009 1:04 pm
by garvinhicking
Hi!

Instead of adding more "switchable" options to the plugin we advocate the use of a customized plugin_categories.tpl template file for your custom template, where you can adapt links to your liking.

However, we appreciate you sharing your patch - technically it is perfectly fine, for anyone wanting to patch the plugin on his own!

(Also note an alternate approach to simply add .category_link_all {display:none} to the templates' style.css file)

Regards,
Garvin

Posted: Fri Jan 30, 2009 3:16 pm
by onli
Though I of course accept this, I don't think that dealing with *.tpl is as user friendly as having something like this be provided within the plugin. But quite possible that I'm overestimating the need for customization of an average serendipity-user.

Anyway, thanks for your feedback.
sincerely

Re: category_plugin: hide frontpage link

Posted: Sun Jun 07, 2009 3:29 pm
by partypie3
I've tried what Garvin suggested with the .tpl suggestion and didn't run into any issues. Thanks very much for this.