====== Categories Plugin ======
^ :!: Obsolete | This plugin will not be developed any further by its author. Use the [[plugin:tag|Tag-PlugIn]]! It does the same and in combination with other components can do much more. |
===== Introduction =====
This [[plugins|plugin]] displays a list of keywords with links to categories the current page belongs to. Those links are marked as [[http://www.technorati.com/tag/|Technorati tags]] and point to the page with the tag name in your wiki. For example for this page I could define "wiki:DokuWiki", "wiki:plugins", "plugin:category", "tag" and "person:Esther_Brunner" as categories:
??wiki:DokuWiki wiki:plugins category :tag person:Esther_Brunner??
This would produce a list that looks like this:((Not exactly: With the plugin installed the list of keywords would be right-aligned.))
----
[[DokuWiki]], [[plugins]], [[plugin:category]], [[:tag]], [[person:esther_brunner|Esther Brunner]]
You can see the plugin in action [[http://www.qwik.ch/playground|here]].
===== Plugin =====
To install, put the following PHP file in ''/lib/plugins/category/syntax.php''.
*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_category extends DokuWiki_Syntax_Plugin {
/**
* return some info
*/
function getInfo(){
return array(
'author' => 'Esther Brunner',
'email' => 'esther@kaffeehaus.ch',
'date' => '2005-07-12',
'name' => 'Category Plugin',
'desc' => 'Displays a list of keywords with links to categories this page belongs to. '.
'The links are marked as tags for Technorati and other services using tagging.',
'url' => 'http://www.dokuwiki.org/plugin:category',
);
}
/**
* What kind of syntax are we?
*/
function getType(){
return 'substition';
}
/**
* Where to sort in?
*/
function getSort(){
return 305;
}
/**
* Paragraph Type
*/
function getPType(){
return 'block';
}
/**
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addSpecialPattern("\?\?.+?\?\?",$mode,'plugin_category');
}
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler){
$match = substr($match,2,-2); // strip markup
$match = explode(' ',$match); // split tags
return $match;
}
/**
* Create output
*/
function render($mode, &$renderer, $data) {
global $ID;
global $conf;
if($mode == 'xhtml'){
$renderer->doc .= '
You can customize the look of the category ''
.category {
padding-top: 3px;
border-top: 2px dotted #dee7ec;
text-align: right;
}
===== Changes =====
* 2005-07-01: style changed from table to right aligned keyword list after a horizontal rule.
* 2005-07-12:
* now allows subnamespaces -- thanks to Geoffrey Roberts for this suggestion!
* if $conf['useheading'] is on the first heading is used instead of the ID
* style changed again to customizable div ''.category''
* 2005-09-13:
* if $conf['useheading'] is enabled display the pagename if there is no heading
> Note that the JavaScript function "svchk()" no longer exists (and is now unnecessary) in Dokuwiki, and does cause JavaScript errors, so references should be removed.
>-- [[todd@rollerorgans.com]] 2007-02-26