Redaktor: Stefan Wajda
|
19.06.2007. |
Mambots and Mambot groups can be used for a variety of purposes. For example,
suppose you want to include an html Templating system like patTemplate
(www.php-tools.de) and load it in your custom Components that use it. Here's a rough outline of the steps that you would take to set this up.
- Create a directory called
patTemplate under the /mambots directory. - Unpack the patTemplate distribution file such that patTemplate.php is
in the new directory you created. All the patTemplate support files
should be in 'another' patTemplate directory. Note that you will also
need to include patError.php and patErrorManager.php in this directory.
The
/mambots/patTemplate directory should now look something like this:
/mambots
/patTemplate
patTemplate.php
patError.php
patErrorManager.php
/patTemplate (many files provided under this directory) - Create an XML setup file for the Mambot listing all the files under the
/mambot/patTemplate directory. It might look something like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall type="mambot" Group="patTemplate" version="4.5.1">
<name>patTemplate</name>
<creationDate>01/09/2004</creationDate>
<version>3.0 Beta 1</version>
<Author>Stephan Schmidt</author>
<license>http://www.gnu.org/copyleft/lgpl.html GNU/LGPL</license>
<authore-mail>schst @php.net</authore-mail>
<authorUrl>www.php-tool.de</authorUrl>
<description>Powerful templating engine</description>
<files>
<filename>patError.php</filename>
<filename>patErrorManager.php</filename>
<filename>patTemplate/Dump/Html.php</filename>
<filename>patTemplate/Dump.php</filename>
<filename>patTemplate/Function/Time.php</filename>
<filename>patTemplate/Function.php</filename>
<filename>patTemplate/InputFilter/StripComments.php</filename>
<filename>patTemplate/InputFilter.php</filename>
<filename>patTemplate/Modifier/HTML/Img.php</filename>
<filename>patTemplate/Modifier/Wordwrapper.php</filename>
<filename>patTemplate/Modifier.php</filename>
<filename>patTemplate/Module.php</filename>
<filename>patTemplate/OutputCache.php</filename>
<filename>patTemplate/OutputFilter/Gzip.php</filename>
<filename>patTemplate/OutputFilter/StripWhitespace.php</filename>
<filename>patTemplate/OutputFilter.php</filename>
<filename>patTemplate/Reader/File.php</filename>
<filename>patTemplate/Reader/IT.php</filename>
<filename>patTemplate/Reader/String.php</filename>
<filename>patTemplate/Reader.php</filename>
<filename>patTemplate/TemplateCache/File.php</filename>
<filename>patTemplate/TemplateCache.php</filename>
<filename mambot="patTemplate">patTemplate.php</filename>
<filename>patTemplate.xml</filename>
</files>
</mosinstall> Notice that the file patTemplate.php is given the "mambot" attribute to
signify that this is the file to be loaded by the Mambot handler. - Zip up the contents of the /joomla/patTemplate directory and install the
Mambot. You should see it listed in the Mambot Manager.
- To use this in your code, you would use something similar to the following:
<a href="http://www.php.net/global">global</a> $_MAMBOTS;
if (!$_MAMBOTS ⇒ loadBotGroup( 'patTemplate' )) {
die( 'This component requires the patTemplate Plugin' );
}
$tmpl =& new patTemplate( 'html' ); There are obviously many other applications for this technique. |