Joomla Custom PHP Content Mambot/Plugin

botPHP_content is a mambot mambot/plugin that allows you to place custom PHP inside a Joomla mambot, thus allowing you to modify the Joomla Articles before it is displayed.

Download

You can download botPHP_content from the Joomla Plugins Download Section of Fiji Web Design.

Installation

The mambot does not require any special installation. At the moment it only supports Joomla 1.0.x. Here is some documentation on how to install a mambot on Joomla 1.0.x.

Documentation, How to

After installing botPHP_content through the Joomla Admin Panel, choose it from the list of installed site mambot so that you can edit its parameters. In the parameters you will find 3 parameters. All three parameters take PHP/HTML/CSS/JavaScript etc.

How to use the "On Preapare" Parameter

The parameter labbelled "On Prepare" takes some PHP code which will modify the $row Object. The $row Object represents the article. The article content is held in the property $row->text.

Example 1: Add a horizontal rule to the end of an article

<?php
$row->text .= '<br />';
?>
This will add a <br /> tag to the end of the article content.

Example2: Replace strings in an article content

<?php
global $mosConfig_sitename;
if (isset($row->text)) {
	$row->text = str_replace('{sitename}', $mosConfig_sitename, $row->text);
}
?>
This will replace all instances of {sitename} with the value of $mosConfig_sitename in the article contents, where $mosConfig_sitename is the name of your Joomla/Mambo website.

How to use the "Before Content" Parameter

The parameter labbelled "Before Content" takes some PHP code which will display above the article. Use the echo() function instead of return() to display content. Note: This parameter only works if your server supports output buffering. Otherwise it will not show anything.

Example 1: Add google adsense code above all articles

<script type="text/javascript"><!--
google_ad_client = "pub-0553268877774585";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "image";
//2007-03-06: fiji web design
google_ad_channel = "9343350244";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "FF6600";
google_color_text = "000000";
google_color_url = "FF6633";
//--></script>

<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
All you need to do is copy and paste google adsense text into the parameter field. The ad will then show above all content items.

Example2: Add Custom CSS to all articles

<style>
h4 { font-weight: bold; }
p { margin-bottom: 10px; }
</style>
Note that this is just an example. CSS inside the HTML Body is invalid xHTML.

How to use the "After Content" Parameter

The "After Content" Parameter is just like the before content parameter, but it places the php/html/css/javascript etc. at the bottom of the article.

Example1: Show the article's last modified and creation date.

<?php
if (isset($row->created)) {
	echo '<p>';
	echo '<b>Created on</b>: '.$row->created;
	if (isset($row->modified) && $row->modified) {
		echo ' <b>Last modified on</b>: '.$row->modified;
	}
	echo '</p>';
}
?>

Frequently Asked Questions

If you have a question, contact us and we will post the FAQ here.

Support and Contacts

Contact US if you need help or have comments.