June 21, 2005
Mambo Island Ads
I've just read How to code a Mambot? and written my very first Mambot.
The code is to place an island ad into a story on a Mambo site.
I've totally mucked about the file called components/com_content/content.php but look for the function show and find this code
PHP:
and change it to
PHP:
Now if you view your articles you'll see that they have {island} in the middle. Now it's time to write the Mambot.
First up there is a simple XML file which you can pick up from the attached zip file and the mambot itself.
PHP:
-
<?php
-
-
-
$_MAMBOTS->registerFunction( 'onBeforeDisplayContent', 'replaceIsland' );
-
-
/**
-
* replace the Island Ad using the island mambot
-
*
-
* <b>Usage:</b>
-
* <code>{island}</code>
-
*
-
*/
-
function replaceIsland( &$row, &$params, $page )
-
{
-
$regex = "#{island}#";
-
-
-
return true;
-
}
-
-
function island_replacer( &$matches)
-
{
-
global $mosConfig_absolute_path;
-
global $sectionName;
-
-
require_once($mosConfig_absolute_path.'/includes/domit/xml_saxy_lite_parser.php');
-
-
$parser = & new SAXY_Lite_Parser();
-
$attribs = $parser->parseAttributes($matches[2]);
-
-
-
-
//code pinched from mod_maxmediamanager
-
-
require_once($mosConfig_absolute_path .'/administrator/max/phpadsnew.inc.php');
-
//zone is hard coded
-
$phpAds_raw = view_raw ('zone:2', 0, '_blank', $sectionName, '0', $phpAds_context);
-
-
//sub out the bad words
-
-
return "<div id='island_outer'>{$str}</div>";
-
}
-
?>
I'm using phpAdsNew to manage the ads and stripping out bad strings, hard coding the zone etc when infact the zone can be parameters.
All that's needed then is to install it - and publish it.
Also on this site
2 Comments »
Leave a comment
Search
Pages
Categories:
Recent Comments
- Michael Brandon-SearchMasters on NBO - National Business Online
- Peter Hodge on Jobleader.co.nz - heard of them? heard…
- James on Domain registration changes we need!
- ghprod on Javascript Test Page
- Bulbboy on Review: Moshi Monsters


A simple example might be a good idea, no?
Got a link?
Comment by Moi — September 23, 2005 @ 7:23 am
This was implemented over at PropertyTalk but isn’t available right now. When I posted this it was pre-release and was live for a bit. Then the content component was swapped for one that allows comments. I need to reapply this hack.
Comment by sarahk — September 23, 2005 @ 9:51 am