Page 1 of 1

Parameters in User Defined Tags?

Posted: Fri Nov 18, 2005 1:23 am
by finster
Hi all,

Just wondering if there is a way to have parameters within user defined tags. I have had a good look around but can't find any information on creating tags.

I basically want to pass in a string to the tag, and for the tag to then spit out a with the string inside.

e.g.{ image_link("hedgehog") } would go to something likeĀ 

I have the PHP ready, I just need to get it into a tag. Or will I have to use a proper tag? Is there any basic info on creating tags/user defined tags?

I have tried testing the basics of this in a user defined tag but it doesn't want to work (smarty errors) : -

name: image_link($fname)
code: echo $fname;


Am I missing something obvious?

Cheers.

Re: Parameters in User Defined Tags?

Posted: Fri Nov 18, 2005 1:30 pm
by Ted
{image_link src='hedgehog'} can be done with:

Code: Select all

echo '<a href="'.$params['src'].'.jpg" target="_blank"><img src="t_'.$params['src'].'.jpg"></a>';

Re: Parameters in User Defined Tags?

Posted: Fri Nov 18, 2005 1:42 pm
by finster
Excellent - thanks very much - thought it could be done - just my syntax. My hedgehog is now being displayed :)

For reference if anybody looks at this again, wishy's code goes in the "code" section of the user defined tag, the "name" doesn't need anything extra - just the name of the tag (in my case "image_link").

Thanks again!