-
Notifications
You must be signed in to change notification settings - Fork 6
Plugin
You can add a new plugin.
XOOPS_TRUST_PATH/modules/widget/plugins/{pluginname}
pluginname/
- config.ini
- plugin.php
- option_form.html
- plugin.html
- language/
- en.php
- ja_utf8.php
type="smarty"
title="html contents with smarty"
description="Add html widget. You can use smarty"
[options]
field[0]="p_content"
default[0]="Hello!"
-
type: Your plugin type. Only one word. You may use alphabet, number
-
title: Your plugin name in 1 line.
-
description: Your plugin description.
-
options: Plugin options administrator assigns when he installs the widget.
-
field[]: Input field name for form field. You should the prefix 'p_'.
-
default[]: You may set default value for field. You must set the same index number as the field's.
Make Widget_{YourPluginType}_Plugin class implements Widget_PluginInterface in class/plugin.interface.php.
Widget_{YourPluginType}_Plugin::execute() is executed before rendering widget. So you may add your process.
Widget_{YourPluginType}_Plugin::fetch() fetch POST request and set them into object. If the POST field name and object field name(defined at config.ini) are the same, they are automatically set and you don't have to set them by yourself.
<?php
class Widget_Twitter_Plugin implements Widget_PluginInterface
{
public static function execute(Widget_InstanceObject &$object)
{
$headerScript = XCube_Root::getSingleton()->mContext->getAttribute('headerScript');
$headerScript->addLibrary("http://widgets.twimg.com/j/2/widget.js", false);
}
public static function fetch(Widget_InstanceObject &$object, $request)
{
}
}
Form template html for option field. Administrator input these field when he install this plugin.
<form>``</form>
tags are generated automatically. So you add form field tags(<input>
, <textarea>
, <select>
, etc.) only.
<div class="control-group">
<label for="p_content" class="control-label required"><{$object->getOptionTitle('p_content')}></label>
<div class="controls" class="span4"><textarea name="p_content"><{$object->getOptionValue('p_content')}></textarea></div>
</div>
Widget View template. You may use $block object and $block->getOptionValue('your_field_name') method in this template.
<div class="content">
<{$block->getOptionValue('p_content')}>
</div>
You may define language in language/{langname}.php file.
ex) en.php, ja_utf8.php
The constant name's prefix is '_WIDGET_PLUGIN_{WIDGET_TYPE}_'.
<?php
define('_WIDGET_PLUGIN_HTML_CONTENT', 'Contents');