Hey
I need to turn every word in a string into an include. So despite my lack of php skills I thought I’d try to build my very first plug-in to handle things, but I’ve run into some issues…
First, the idea is to take a custom field and turn every word in that field into an embed, or in my case, an include.
{exp:weblog:entries weblog="main"}
{exp:explodeinclude url="http://www.example.com/index.php/modules/"}
{modules}
{/exp:explodeinclude}
{/exp:weblog:entries}
Should be simple, right? Well, below is what I’ve got so far. Please bare in mind that I don’t actually know php… 😛
class Explodeinclude
{
var $return_data = "";
function Explodeinclude()
{
global $TMPL;
$url = $TMPL->fetch_param('url');
$url = str_replace( "/","/",$url);
// Input string
$string = $TMPL->tagdata;
// Create an array from input
$modules = explode(',',strtolower($string));
// Add all found words to the new array
foreach($modules as $module){
include($url.$module);
}
$this->return_data = $TMPL->tagdata;
}
}
The issues I’ve got are:
Even if placed under a heading and other content, the code rendered by the plugin is displayed at the very top of the page.
A space is placed in front of the $module segment of the url.
It would be great if I could just specify the template group and template instead of the full url. Although I’m not sure if it’ll work as I may have to use the server path anyway…
Any help would be much appreciated!
Tnx /André
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.