Page 1 of 1

embed plugins using smarty

Posted: Sat Sep 29, 2007 2:53 pm
by kadata
I have embedded my blog into a website I have already designed but have been having a few issues trying to embed the plugins that go along with it (categories, pollbox, etc). After many many hours of searching how to embed the plugins, I have found a way to use the {php} {/php} tags inside of a smarty template to embed a plugin:

Code: Select all

{php}

$title = '';
$plugin =& serendipity_plugin_api::load_plugin('@serendipity_categories_plugin:237bc6a52b25c0efb12c7fca28458a69');
$plugin->generate_content($title);
{/php}
But, I'm curious on a few things:

1. Is there a way to create a smarty tag that I can use instead of the php?
2. Can the title of the plugin be used instead of the ID? I would rather not have to go to the database everytime I want to add another plugin to the template.

Any help would be appreciated!

Re: embed plugins using smarty

Posted: Sat Sep 29, 2007 3:59 pm
by garvinhicking
Hi!

You don't need to use raw PHP, there's a smarty function which does the loading of plugins for you:

http://www.s9y.org/78.html
2. Can the title of the plugin be used instead of the ID?
Nope. Only the classname OR the unique ID can be used.

Is there a reason you want to call each plugin specifically, instead of using {serendipity_printSidebar}?

Regards,
Garvin

Posted: Sun Sep 30, 2007 7:03 pm
by kadata
I have tried using

Code: Select all

{serendipity_showPlugin class="serendipity_event_pollbox" side="hidden" negate="null"}
but received the following error:

Fatal error: Smarty error: [in kahome2.tpl line 26]: syntax error: unrecognized tag 'serendipity_showPlugin' (Smarty_Compiler.class.php, line 590) in /[absolute path]/bundled-libs/Smarty/libs/Smarty.class.php on line 1095

I have all the plugins currently in the hidden column, since I do not want them to show up on the actual blog, but in certain areas of my webpage. And I want to have certain plugins shown in my own sidebar on my webpage. I want to show the plugin even when I'm not showing the main page of the blog.

Where would I find the classname? I could not find the folder for the category plugin in the plugin folder under the serendipity folder.

Posted: Mon Oct 01, 2007 9:16 am
by garvinhicking
Hi!

You can only show sidebar plugins, not event plugins! For event plugins you need to use serendpity_hookPlugin, documented on the same URL I gave you.

Regards,
Garvin

Posted: Mon Oct 01, 2007 4:26 pm
by kadata
I tried using the

{serendipity_hookPlugin hook="serendipity_event_pollbox" hookAll="true"}

code and received the error:

Fatal error: Smarty error: [in kahome2.tpl line 26]: syntax error: unrecognized tag 'serendipity_hookPlugin' (Smarty_Compiler.class.php, line 590) in /[absolute path]/bundled-libs/Smarty/libs/Smarty.class.php on line 1095

It's starting to seem I can only use the PHP code to make this work. And also, I do not have a folder for the categories plugin (the one that lists all the categories and the number of entries inside those categories) so I'm unable to use the name for it.

Posted: Mon Oct 01, 2007 9:56 pm
by garvinhicking
Hi!

:-)

Did you read the full posting? There is a fundamental difference between a CLASSNAME (serendipity_event_pollbox) and the name of an EVENT HOOK ("frontend_display").

What exactly do you try to do?

For displaying the pollbox, you must use the sidebar plugin. Then you can display the pollbox somewhere else if you use the {serendipity_showPlugin ...="serendipity_plugin_pollbox"...} function call.

The categories plugin is called "serendipity_categories_plugin", it is one of the few internal plugins that are bundled inside thefile include/plugin_internal.inc.php.

Regards,
Garvin

Posted: Mon Oct 01, 2007 10:17 pm
by kadata
Thanks! Got it working now. I took the code from here and combined it with

{serendipity_showPlugin class="serendipity_categories_plugin" side="hidden" negate="null"}

Now I was wondering how it would be possible to include external template files to display the blog? Basically, what I'm trying to do is use the serendipity admin interface to write and create the rss feeds for the blog, but want to contain everything inside of my own webpage. The reason behind this, is that I have files that are on the root of the webpage that I want to still be displayed when the user is inside the blog. I cannot put some of these files into the template directory of serendipity or else they will not work correctly. I have tried using the absolute path to direct it to the correct file, but I receive the following error:

Warning: Smarty error: (secure mode) accessing "/[absolute path]/[filename].php" is not allowed in /[absolute path]/bundled-libs/Smarty/libs/Smarty.class.php on line 1095

Another question about the categories plugin... Can the links be changed so not to go to the blog directly, but to different pages / send in different parameters to the $serendipity['GET']['category'] function?

Posted: Fri Oct 05, 2007 8:51 am
by garvinhicking
Hi!

You could try to disable the smarty security, by editing (or creating) a config.inc.php file inside your main s9y template directory (where you also inserted the showPlugin calls):

Code: Select all

<?php
$serendipity['smarty']->security = false;
?>
(I'm not sure I understand what you're trying to do, though :) )
Another question about the categories plugin... Can the links be changed so not to go to the blog directly, but to different pages / send in different parameters to the $serendipity['GET']['category'] function?
Uh, you would need to patch the output of the plugin. Maybe you can already do that by editing the plugin_categories.tpl file (first configure the categories plugin through the backend to enable the use of smarty for its output, otherwise its output comes straight from the PHP).

Regards,
Garvin

Posted: Mon Oct 08, 2007 4:29 am
by kadata
I got this working just by using a regular smarty template, but calling in the serendipity library instead of the smarty library that I had installed as well. Everything seems to be working great! Thanks for all the hard work!