It's better when it's simple

User Tools

Site Tools


garfield plugin

Compatible with DokuWiki

No compatibility info given!

plugin Will show a daily garfield comic.

Last updated on

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to webcomics, xkcd

Tagged with images, media, random


With the Tag [GARFIELD] you can include a Garfield comic, which will change every day.

Plugin is similar to Dilbert Plugin - It only shows a Garfield comic instead of Dilbert.


Save the following code into syntax.php and copy it into folder: /lib/plugins/garfield/

 * Plugin Now: Inserts a timestamp.
 * @license    GPL 2 (
 * @author     Christoph Lang <>
// based on
// must be run within DokuWiki
if (!defined('DOKU_INC')) die();
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_garfield extends DokuWiki_Syntax_Plugin {
    function getInfo() {
        return array(
        'author'  => 'Christoph Lang',
        'email'   => '',
        'date'    => '2009-06-22',
        'name'    => 'Garfield Plugin',
        'desc'    => 'It displays a daily Garfield Comic. Based on Dilbert Plugin.',
        'url'     => ''
    private function _listhd() {
        require_once(DOKU_INC . 'inc/HTTPClient.php');
        $url = '';
        $ch = new DokuHTTPClient();
        $piece = $ch->get($url);
        $xml = simplexml_load_string($piece);
        $pre  = '';
        $post = '.gif';
        $a = explode($pre,  (string)$xml->channel->item->description);
        $b = explode($post, $a[1]);
        $feed_contents .= '<a href="' . $url . '/" alt="GARFIELD">' .
        '<img src="' . $pre . $b[0] . $post . '" alt="GARFIELD"/></a>'. "\n";
        return $feed_contents;
    function connectTo($mode) {
        $this->Lexer->addSpecialPattern('\[GARFIELD\]', $mode, 'plugin_garfield');
    function getType() { return 'substition'; }
    function getSort() { return 667; }
    function handle($match, $state, $pos, &$handler) {
        return array($match, $state, $pos);
    function render($mode, &$renderer, $data) {
        if ($mode == 'xhtml') {
            $renderer->doc .= $this->_listhd();
            return true;
        return false;

hey ? what is “simplexml_load_string” ? my dokuwiki is not able to find it !

simplexml_load_string is used to load and process an xml-file (here: the rss feed with the pictures)
plugin/garfield.txt · Last modified: 2013-09-17 15:39 by

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki