Page 1 of 1
Move sidebar items
Posted: Sun Apr 10, 2005 1:59 am
by mikkel_h
Hi.
I have a standard three-column layout on my website,
http://www.mzh.dk.
I have placed the actual blog (i.e. the entries) in the middle column, but now I would like to know if it is possible to display some of the built-in sidebar items (calendar and archive) in the left or right column.
The site is PHP-based, so I have the possibility of doing server-side includes, but I don't know how to generate the actual sidebar items outside Serendipity - is it at all possible?
Mikkel
Re: Move sidebar items
Posted: Sun Apr 10, 2005 3:26 pm
by garvinhicking
Yes, this is possible.
You can use this PHP code snippet:
Code: Select all
<?php
chdir('/home/garvin/cvs/serendipity/serendipity_MERGE/'); // This needs to be changed to the path to your blog installation!
include_once('serendipity_config.inc.php');
print_r(serendipity_plugin_api::generate_plugins('right', 'div'));
?>
This would create all right sidebar elements you have configured in your serendipity.
Another solution is to create single instances of a plugin, which could also be set to a 'hidden' display within the serendipity plugin manager:
Code: Select all
<?php
chdir('/home/garvin/cvs/serendipity/serendipity_MERGE/'); // This needs to be changed to the path to your blog installation!
if (!headers_sent()) {
session_start();
}
include_once('serendipity_config.inc.php');
serendipity_login();
if (!headers_sent()) {
header('Content-Type: text/html; charset='. LANG_CHARSET);
}
$subdir = '';
$side = 'left';
$pluginname = '@serendipity_categories_plugin:44141a11c520f4c612c733f9b7187b95';
$plugin =& serendipity_plugin_api::load_plugin($pluginname, 0, $subdir);
$class = get_class($plugin);
$title = '';
ob_start();
$show_plugin = $plugin->generate_content($title);
$content = ob_get_contents();
ob_end_clean();
if ($show_plugin !== FALSE) {
$pluginData = array(array('side' => $side,
'class' => $class,
'title' => $title,
'content' => $content));
}
serendipity_smarty_init();
$serendipity['smarty']->assign(
array(
'plugindata' => $pluginData,
'pluginside' => ucfirst($side)
)
);
serendipity_smarty_fetch('sidebar_'. $side, 'sidebar.tpl', true);
$serendipity['smarty']->display('sidebar.tpl');
?>
Set $pluginname to the full instance name of the plugin you want to show.
The example are based on Serendipity 0.8. You could also go the easier way and integrate your site into the Smarty Templates of Serendipity instead, or put your own left and right sidebar into HTML Nuggets or seperate PHP Include Plugins and then make Serendipity output your whole page, and not your page include Serendipity.
Regards
Garvin
Re: Move sidebar items
Posted: Mon Apr 11, 2005 4:09 am
by Guest
garvinhicking wrote:
Code: Select all
<?php
chdir('/home/garvin/cvs/serendipity/serendipity_MERGE/'); // This needs to be changed to the path to your blog installation!
include_once('serendipity_config.inc.php');
print_r(serendipity_plugin_api::generate_plugins('right', 'div'));
?>
This worked like a charm - thanks a million!
Mikkel