Page 1 of 1

Standalone Plugin

Posted: Sat Jan 08, 2005 12:21 am
by Guest
Is there a away to run a plugin standalone?

Let's say I only wanted the calander, or the shoutbox, or any other plugin to appear on a page without the rest of the blog...is this possible?

thanks

Re: Standalone Plugin

Posted: Sat Jan 08, 2005 3:33 pm
by garvinhicking
Yes, there is. You can use this PHP code.

First the one for Serendipity 0.7:

Code: Select all

<?php # $Id: index.php,v 1.69 2005/01/03 18:03:39 tomsommer Exp $

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);
}

$tagname    = 'div';
$side       = 'left';
$pluginname = 'serendipity_plugin_blah:13248f73323987de7987';

echo "<$tagname id=\"serendipity" . ucfirst($side) . "SideBar\">\n";
$plugin =& serendipity_plugin_api::load_plugin($pluginname);
$title  = '';

ob_start();
if ($plugin->generate_content($title) !== false) {
    $content = ob_get_contents();
    $class   = get_class($plugin);
    ob_end_clean();

    echo "    <div class=\"$plugin->wrap_class sidebar_wrap_$class\">\n";
    if (!empty($title)) {
        echo "        <h3 class=\"$plugin->title_class
sidebar_title_$class\">$title</h3>\n";
    }
    echo "        <div class=\"$plugin->content_class sidebar_content_$class\">\n";
    echo "            $content\n";
    echo "        </div>\n";
    echo "    </div>\n";
} else {
    ob_end_clean();
}

echo "</$tagname>\n";

/* vim: set sts=4 ts=4 expandtab : */
?>
This for Serendipity 0.8:

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');

?>
In both files you need to adjust $pluginname to match the name of the plugin as found in your serendipity_plugins DB table. (with the :908234098234 md5 stuff).

Regards,
Garvin