This is possible via templating, yes.
You can achieve this with 3 methods:
1. The easiest way requires Serendipity 0.9.
Edit your index.tpl template. Take a look around where you want to tab-menu to be. Code it something like this:
Code: Select all
<div class="tabmenu">
<a href="/serendipity/categories/1-X">Cat 1</a>
<a href="/serendipity/categories/2-X">Cat 2</a>
<a href="/serendipity/categories/3-X">Cat 3</a>
</div>
You will also need CSS to display those as a tablist. This will not be covered here, there are a lot of CSS tutorials available.
The next step is to make the current tab active. For that you can add some Smarty things:
Code: Select all
<div class="tabmenu">
<a href="/serendipity/categories/1-X" {if $category == 1}class="active"{/if}>Cat 1</a>
<a href="/serendipity/categories/2-X" {if $category == 2}class="active"{/if}>Cat 2</a>
<a href="/serendipity/categories/3-X" {if $category == 3}class="active"{/if}>Cat 3</a>
</div>
This will make the selected tab active. Now this method has the disadvantage that you need to enter the list of categories manually to your template, but the advantages that its easy to do and no plugin is necessary.
2. (This method also works with Serendipity 0.

You could make the same with a plugin that emits the same HTML code. Then instead of printing the HTML in your stylesheet you would only place this code:
Code: Select all
<div class="tabmenu">
{serendipity_hookPlugin hook="frontend_categorytabs" hookAll=true}
</div>
And then make up a simple plugin like this, save it in your plugins directory and install it via the plugin config:
Code: Select all
<?php # $Id: serendipity_event_spartacus.php 346 2005-08-01 17:35:25Z garvinhicking $
class serendipity_event_categorytabs extends serendipity_event
{
var $title = 'Category Tabs';
function introspect(&$propbag) {
global $serendipity;
$propbag->add('name', 'Category Tabs');
$propbag->add('description', '');
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.0');
$propbag->add('requirements', array('serendipity' => '0.8'));
$propbag->add('event_hooks', array('frontend_categorytabs' => true));
$propbag->add('groups', array('TEMPLATES'));
}
function generate_content(&$title) {
$title = $this->title;
}
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
if ($event == 'frontend_categorytabs') {
$cats = serendipity_walkRecursive(serendipity_fetchCategories(), 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ($cats as $cat) {
if ($cat['depth'] > 0) continue;
if (function_exists('serendipity_categoryURL')) {
$link = serendipity_categoryURL($cat, 'serendipityHTTPPath');
} else {
$link = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $cat['categoryid'], 'title' => $cat['category_name'])), 'serendipityHTTPPath');
}
echo '<a href="' . $link . '" ' . ($serendipity['GET']['category'] == $cat['categoryid'] ? 'class="tab_active"' : '') . '>' . htmlspecialchars($cat['category_name']) . '</a>' . "\n";
}
return true;
}
return false;
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>
You can modify method 1 to work with 0.8 if you put a config.inc.php file into your template directory with this content:
Code: Select all
<?php
$serendipity['smarty']->assign('category', $serendipity['GET']['category']);
?>
3. If you don't want to depend on a plugin, you can put the whole way of fetching the categories into the template's config.inc.php:
Code: Select all
<?php
function smarty_getCategories($params, &$smarty) {
$cats = serendipity_walkRecursive(serendipity_fetchCategories(), 'categoryid', 'parentid', VIEWMODE_THREADED);
$returncats = array();
foreach($cats AS $cat) {
if ($cat['depth'] > 0) continue;
$cat['url'] = serendipity_categoryURL($cat, 'serendipityHTTPPath');
$cat['category_name'] = htmlspecialchars($cat['category_name']);
$returncats[] = $cat;
}
return $returncats;
}
$serendipity['smarty']->register_function('smarty_getCategories', 'smarty_getCategories');
$serendipity['smarty']->assign('category', $serendipity['GET']['category']);
$serendipity['smarty']->assign('categories', smarty_getCategories(null, $serendipity['smarty']));
?>
and then use this in your index.tpl:
Code: Select all
<div class="tabmenu">
{foreach from=$categories item="ccategory"}
<a href="{$ccategory.url}" {if $ccategory.categoryid == $category}class="tab_active"{/if}>{$ccategory.category_name}</a>
{/foreach}
</div>
I hope you see the grace in the flexibility of Serendipity. I think MySchizoBuddy from the forums has created a tab-based layout already, maybe he's willing to share?
Regards,
Garvin