Help programming User Defined Tag to call Smarty Function {mailto}

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
websherpa

Help programming User Defined Tag to call Smarty Function {mailto}

Post by websherpa »

I am not a proficient PHP coder (in fact less than a hack), but I need help to accomplish this:

Within a template I have set a hidden content block to capture an email address in the Page Editor, then pass it to the {mailto} Smarty, thus:

Code: Select all


<div id="hidden">{content block="email" oneline='true' wysiwyg='false' assign=email1}</div>
{mailto address=$email1 encode='hex'}

All well and good except that if the "email" block is empty, then I get an error, so I am wondering how to correctly code either the template or call some script in a User Defined Tag to only call the Smarty {mailto} if the $email1 isn't empty? 

I thought of doing something this:

Code: Select all


if ( isset($params['email1']) && !empty($params['email1'])) { 

then execute a {mailto ...};
}

But I don't know my PHP or smarty well enough to know how to form the {mailto} call within a PHP script - if it can be done.

Any help on this?  Thank you.  I am learning gobs but this one I have hit the wall of my own grasp of PHP syntax.

Wayne
Last edited by websherpa on Tue Dec 05, 2006 5:18 am, edited 1 time in total.
cyberman

Re: Help programming User Defined Tag to call Smarty Function {mailto}

Post by cyberman »

I'm not a coder for real too but I suggest you should use Smarty pure :)

Code: Select all

{if $email1 neq ''}
   {mailto ...}
{/if}
websherpa

Re: Help programming User Defined Tag to call Smarty Function {mailto}

Post by websherpa »

Well there you go, I knew it would be something simple.  Thank you!

I am curious still, however, whether you can call or set up a smarty function with a parameter from within PHP and and example of just how you would code it.
cyberman

Re: Help programming User Defined Tag to call Smarty Function {mailto}

Post by cyberman »

You have to enable "Use smarty php tags" in config.php. Then you can use too in template

Code: Select all

{php}
if ( isset($params['email1']) && !empty($params['email1'])) {
{/php}

   {mailto ...}

{php}
}
{/php}
Locked

Return to “CMSMS Core”