The overview: You create a zip file that you can use to do an install using Mambo installer
What is needed: bot_yourmambot.php and bot_yourmambot.xml. Use these two files to create bot_yourmambot.zip
What is bot_yourmambot.xml: This is a file that the installer need to know some info regarding your mambot and do the install
What is bot_yourmambot.php: This is a file where you put the logic of your mambot to be executed by Mambo
Here is a sample content would go in your bot_yourmambot.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall version="4.5.1" type="mambot" group="content">
<name>YourMambotName</name>
<creationDate>mm/dd/yyyy</creationDate>
<author>Your Name</author>
<copyright>This module is released under the GNU/GPL License</copyright>
<authorEmail>
</authorEmail>
<authorUrl>http://www.yoursite.com</authorUrl>
<version>0.1</version>
<description>Some description of your mambot</description>
<files>
<filename mambot="yourmambot">yourmambot.php</filename>
</files>
<params>
</params>
</mosinstall>
Here is a more expanded info on params
<params>
<param name="youralign" type="list" default="center" label="Align" description="Select left, right or center">
<option value="right">Right</option>
<option value="left">Left</option>
<option value="center">Center</option>
</param>
</params>
Note: There are more type available but I don't have them all here you will need to hack the code to find out more or when I do I will update this article later.
Here is a content would go in your bot_yourmambot.php
Let say you want to just show "me, mambot hello" message in your content. This is very simple version of a mambot like a "hello world" type you can expand on this to utilize the parameters as described above to add more customization to your mambot or add more complex routine.
It is only limit to your imagination!
<?php // beginning of your mambot
// must have to protect from potential security risk
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
// declare your global
global $published;
// triggers: onPrepareContent, onAfterDisplayTitle,, onBeforeDisplayContent, onAfterDisplayContent
// mambot will be call at "onPrepareContent" trigger
$ttype = "onPrepareContent";
// set which call back to use
if (strtolower($ttype)=='onpreparecontent') {
$whichfunc="callback_mambot_in_content";
}
// register your mambot to the trigger and your function to be called
$_MAMBOTS->registerFunction( $ttype, $whichfunc ) ;
// Your functions to be call back
function callback_mambot_in_content( $published, &$row, &$params, $page=0 ) {
$id="";
if (!$published) return false;
if (isset($row->id)) $id=$row->id;
$row->text = $row->text . "me, mambot hello";
return true;
}
// end of mambot
?>