Assistance Required: My First Plugin
Posted: Sat Sep 16, 2006 10:48 pm
Would appreciate some assistance from the vets. I have read the documentation, and am using the html_nugget event plugin as reference.
Goal:
To simply print a list in the header of the blog.
example: <ul> <li><a href="$path">$linkname</li></ul>
Once I learn this I should be able to change it to what I really want.
Im going to go over section by section, if I am misinterpreting something please correct me.
Above reads in the values of certain varibles decalred in a different file.
I took this right from the html nugget plugin, I noticed all plugins pretty much have this.
Q1: What does the stackable property do?
Q2: Seeing as I want my list to display in the header it is frontend related? Groups I think just means where your plugin will apply?
Q3: This is the actual hook we want to use, so for me I want to be in the frontend header?
Q4: Configuration property would defining those values that would be changed in the admin of the plugin I assume?
Q5: This method to me looks like it would only configure the configuration property defined earlier, but looks like it could be called with any property defined earlier. Im assuming this was done for other parts of the code?
Q6: I dont think I need this besides the $title. As far as my reading got me, this is only used for sidebar plugins.
Q7: I think this is where the meat of my plugin should be, and if someone could explain to me how I use the hooks to pass my information to the page? I just want to print <ul><li><a href="$path">$linkname</li></ul>
Thanks for any help anyone gives.
Goal:
To simply print a list in the header of the blog.
example: <ul> <li><a href="$path">$linkname</li></ul>
Once I learn this I should be able to change it to what I really want.
Im going to go over section by section, if I am misinterpreting something please correct me.
Code: Select all
<?php
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include dirname(__FILE__) . '/lang_en.inc.php';
Code: Select all
class serendipity_event_page_nugget extends serendipity_event
{
//introspect defines all data for the plugin
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_NAVBAR_NAME);
$propbag->add('description', PLUGIN_NAVBAR_DESC);
$propbag->add('stackable', true);
$propbag->add('author', 'CR');
$propbag->add('version', '0.1');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
Q1: What does the stackable property do?
Code: Select all
$propbag->add('groups', 'FRONTEND_ENTRY_RELATED');
Code: Select all
$propbag->add('event_hooks', 'frontend_header');
Code: Select all
$propbag->add('configuration', array('linkname','path'));
return true;
}
Code: Select all
function introspect_config_item($name, &$propbag)
{
//I think this assumes we are ONLY modifying configuration
switch($name) {
//title1
case 'linkname':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_LINK_NAME);
$propbag->add('description', PLUGIN_LINK_NAME_DETAILS);
$propbag->add('default', '');
break;
case 'path':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_PATH);
$propbag->add('description', PLUGIN_PATH_DETAILS);
$propbag->add('default', '');
break;
default:
return false;
}
return true;
}
Code: Select all
function generate_content(&$title)
{
$title = $this->get_config('title');
}
Code: Select all
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
$linkname = $this->get_config('linkname');
$path = $this->get_config('path');
}
}
Thanks for any help anyone gives.