Compatible with DokuWiki
> 2009-02-14, 2008-05-05
Similar to meta_yaml
2010-11-29: The plugin gets a new maintainer within the next days (Michael Klier→Andreas Haerter), stay tuned. Details: 1, 2, 3. Chi: Thank you for your work.
| Download | plugin-metaheaders.tgz |
|---|---|
| Github URL | https://github.com/andreashaerter/dokuwiki-plugin-metaheaders |
This action plugin allows to add/remove meta headers dynamically to your Wiki pages.
Download the archive and unpack it into <dokuwiki>/lib/plugins.
The plugin is also available via git.
% cd <dokuwiki>/lib/plugins % git clone git://github.com/andreashaerter/dokuwiki-plugin-metaheaders.git metaheaders
| At the moment there's no admin plugin available to modify the configuration of this plugin, but I plan to add one in the near future. For now you have to edit the configuration file with an UTF-8 capable text editor of your choice |
|---|
After you've installed the plugin you have to create a file named <dokuwiki>/conf/metaheaders.conf.php. The plugin uses simple PHP arrays to hold the data for interacting with the meta headers.
To remove some headers, for example if you like to replace them with your own (like RSS feeds for example) you have to use the $clear array. Each array item will be matched against the used metaheaders, only if all “keywords” match the header is removed from the output.
The following example will remove all RSS feed headers from the headers output.
$clear[] = array ( 'type' => 'application/rss+xml' );
The following example will remove only the RSS feed for the recent changes (because it will also match against the “title”).
$clear[] = array ( 'type' => 'application/rss+xml', 'title' => 'Recent Changes' );
The plugin also supports a cond (condition) array key. This one can be set to a regular expression which will be matched against the current page id. The following example will remove all RSS headers for pages in the namespace blog.
$clear[] = array ( 'type' => 'application/rss+xml', 'cond' => '^blog:*' );
The plugin uses the $headers array in the configuration for adding new meta headers. This array holds two subarrays link and meta for those two header types.
The following example adds a new RSS header to every page.
$headers['link'][] = array( 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => 'Blog RSS', 'href' => 'http://feeds.feedburner.com/blog_feed' );
You can also use the cond array key to add a header only for a given page/namespace. The following will add the above RSS header only for pages in the namespace blog.
$headers['link'][] = array( 'type' => 'application/rss+xml', 'rel' => 'alternate', 'title' => 'Blog RSS', 'href' => 'http://feeds.feedburner.com/blog_feed', 'cond' => '^blog:*' );
The following example will add a new meta header DC.title to every page on the Wiki.
$headers['meta'][] = array( 'name' => 'DC.title', 'content' => 'yourdomain.org' );
Again you can use the cond array key to restrict the addition of the header to certain pages/namespaces.
$headers['meta'][] = array( 'name' => 'DC.title', 'content' => 'yourdomain.org', 'cond' => '^blog:.*' );
Finally you can use substition patters in each value of the array items in the $header array which will be replaced with the appropriate content (if however, the values are empty the headers will not be added!).
The following patterns are supported. All values are looked up in the global $INFO array, if they're not present the header isn't added!
| Pattern | Replace Value |
|---|---|
@ID@ | The Wiki Page ID |
@AUTHOR@ | The author name |
@CREATED@ | The creation date of the page |
@LASTMOD@ | Last modification date |
@ABSTRACT@ | The first paragraph of the current page |
@TITLE@ | The page title |
@RELATION@ | Pages that link back to the viewed page |
@CONTRIBUTORS@ | Comma separated list of Wiki users who have contributed to a page |
( I am thinking of a more dynamic way for these replacements so that this plugin can be used with all information which is hold in a page meta data or optionally set with the meta plugin )
The following example adds a new header with the abstract description of a page.
$headers['meta'][] = array ( 'name' => 'description', 'content' => '@ABSTRACT@' );
A complete changelog is available here.
Please report bugs and feature requests at the bug tracker.
This plugin works great. I have only one problem: I want to remove the meta tag “keywords” and add my own keywords tag. To add my own keyword tag is no problem but I am not able to clear the keywords tag generated by DokuWiki. So I have two keyword tags per page at the moment. http://www.bonsaifreunde.at
I would be pleased if you would help me.
Reinhard
Try this:
<?php $clear[] = array ( 'name' => 'keywords' );