This is a simple plugin to show how the "Flux CMS"-pluginsystem basically works.
Note: This is not included in the sourcecode, so if you want to play with it, you'll have to place the files in the appropriate folders by yourself.
BX_INC_DIR.'bx/plugins/helloworld.php'
<?php
/*
* Simple HelloWorld-Plugin
*
* BX_INC_DIR.'bx/plugins/helloworld.php'
*/
/**
* This plugin does not really do anything. It's just a simple example
* of how a plugin is workting.
*
* calling it on e.g. /hello will output "Hello World"
* calling it on e.g. /hello/foo will output "Hello foo"
*
* To use this plugin in a collection, put the following into .configxml
***
<bxcms xmlns="http:>
<plugins>
<parameter name="xslt" type="pipeline" value="helloworld.xsl"/>
<extension type="html"/>
<plugin type="helloworld">
</plugin>
<plugin type="navitree"></plugin>
</plugins>
</bxcms>
*
* See also the helloworld.xsl for the actual output
*/
class bx_plugins_helloworld extends bx_plugin implements bxIplugin {
static public $instance = array();
protected $res = array();
public static function getInstance($mode) {
if (!isset(self::$instance[$mode])) {
self::$instance[$mode] = new bx_plugins_helloworld($mode);
}
return self::$instance[$mode];
}
protected function __construct($mode) {
$this->mode = $mode;
}
public function getContentById($path, $id) {
$dom = new DomDocument();
$root = $dom->createElement("hello");
$root = $dom->appendChild($root);
$dirname = dirname($id);
if($dirname !== "."):
$root->appendChild($dom->createTextNode($dirname));
else:
$root->appendChild($dom->createTextNode("World"));
endif;
return $dom;
}
public function isRealResource($path , $id) {
return true;
}
}
?>
helloworld.xsl
Place this in your themes folder and name it helloworld.xsl:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http: xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xhtml">
<xsl:import href="master.xsl"/>
<xsl:import href="../standard/common.xsl"/>
<xsl:output encoding="utf-8" method="xml" doctype-system="http: doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/>
<xsl:template name="content">
<h1>Hello <xsl:value-of select="/bx/plugin/hello" /></h1>
</xsl:template>
</xsl:stylesheet>
Add Comment