Page 1 of 1

how to include module call in UDT IF statement

Posted: Wed Jun 06, 2007 8:09 pm
by jmcgin51
Greetings,

I have a UDT that looks something like this:

------------------------------
$test = $_GET['test'];

if($test == "basic"){
    echo "{cms_module module='Quizzard' quiz_id='5'}";
}
------------------------------

This UDT is supposed to get the "test" variable from the URL, and if the "test" variable equals "basic", then the UDT should call the Quizzard module, quiz #5.  Instead, unfortunately, the UDT simply prints "{cms_module module='Quizzard' quiz_id='5'}" on the page, readable by the visitor.

How can I get the UDT to interpret the module tag correctly so that it calls the module instead of printing text?  I've also tried this variant of the code above, but I just get an "invalid code" error.

-------------------------------
$test = $_GET['test'];

if($test == "basic"){
    {cms_module module='Quizzard' quiz_id='5'};
}
------------------------------

I also tried:
-----------------------------
$test = $_GET['test'];

if($test == "basic"){
    echo "{cms_module module='Quizzard' quiz_id='5'}";
}
----------------------------
which doesn't throw errors, but also doesn't do anything at all on the page where I call the UDT.

Would appreciate any help.  I think there must be a simple solution, but I'm an absolute newbie to PHP/Smarty coding and I have no idea where to start.

Re: how to include module call in UDT IF statement

Posted: Wed Jun 06, 2007 10:20 pm
by calguy1000
You can probably use the smarty eval function, or the ProcessTemplateFromData function (available via search) to do that.

Re: how to include module call in UDT IF statement

Posted: Thu Jun 07, 2007 3:16 am
by jmcgin51
Thanks for the response, Calguy.  I did see something about "ProcessTemplateFromData", but I have no idea what it is or how to implement it in this code.  Not sure about the Smarty eval function, either.