PDA

View Full Version : How to .. ? [help creating addons]


sliver
09-08-2008, 05:20 PM
Hi all

i'm a newbie scripting with php-mysql and i've problem writing an addon.
I want to do in mysecretaddon.php something like this:

if($var==1){
$secret = '<GOOGLEMAP>';
}elseif($var==2){
$secret = '<THUMBNAILS>';
}else{
$secret = '<ANOTHERTAG>';
}

$tpl = str_replace("<SECRETADDON>",$secret,$tpl);

but when i try it doesn't work...
so there's any workarount to execute <TAG> from a php addons file?

thank you very much

jaywilliams
09-08-2008, 06:28 PM
You're very close. But template tags only work inside templates, not inside PHP.
What you need is the actual variables that those tags are referencing.

So if you search the code for the template tag, <IMAGE_ID> for example. You'll find that tag defined on line #791 in index.php. It will look something like this:

$tpl = ereg_replace("<IMAGE_ID>",$image_id,$tpl);


So if you want to use that tag in your code, you can simply reference the $image_id variable that it uses.

Hopefully my explanation makes sense. :)