View Source:
Help/HelloWorldPlugin
Note:
This page has been locked and cannot be edited.
A simple example plugin. <<HelloWorld salutation="Hello," name="Wiki User" >> From the source of this page: {{{ <<HelloWorld salutation="Hello," name="Wiki User" >> }}} ---- ~PhpWiki's plugin architecture allows you to add custom page elements to your wiki. All you have to do is extend (subclass) the ~WikiPlugin class and create your output via the run() method, dependent on the Wiki- or Request arguments, * either with the predefined HTML classes to create valid XHTML, * or by using templates, which are easier customizable, but generally more a mess to use and easier to create invalid XHTML. <<PhpHighlight /** * A simple demonstration WikiPlugin. * * Usage: * <<HelloWorld> > * <<HelloWorld * salutation="Greetings, " * name=Wikimeister * > > * <<HelloWorld salutation=Hi > > * <<HelloWorld name=WabiSabi > > */ // Constants are defined before the class. if (!defined('THE_END')) define('THE_END', "!"); class WikiPlugin_HelloWorld extends WikiPlugin { // Five required functions in a WikiPlugin. function getName () { return _("HelloWorld"); } function getDescription () { return _("Simple Sample Plugin"); } // Establish default values for each of this plugin's arguments. function getDefaultArguments() { return array('salutation' => "Hello,", 'name' => "World"); } function run($dbi, $argstr, $request) { extract($this->getArgs($argstr, $request)); // Any text that is returned will not be further transformed, // so use html where necessary. $html = HTML::samp(fmt('%s: %s', $salutation, WikiLink($name, 'auto')), THE_END); return $html; } }; >> <noinclude> ---- [[PhpWikiDocumentation]] [[CategoryWikiPlugin]] </noinclude>
Please enable JavaScript to view the
comments powered by Disqus.
HollenbackDotNet
Home Page
Popular Pages
All Categories
Main Categories
General Interest
Geek Stuff
DevOps
Linux Stuff
Pictures
Search
Toolbox
RecentChanges
RecentNewPages
What links here
Printable version
AllPages
RecentChanges
Recent Changes Cached
No changes found
Favorite Categories
ActionPage
(150)
WikiPlugin
(149)
GeekStuff
(137)
PhpWikiAdministration
(102)
Help/PageList
(75)
Help/MagicPhpWikiURLs
(75)
Blog
(69)
Pictures
(60)
GeneralInterest
(44)
LinuxStuff
(38)
Views
View Page
View Source
History
Diff
Sign In