how to include module call in UDT IF statement

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.
Post Reply
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

how to include module call in UDT IF statement

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: how to include module call in UDT IF statement

Post by calguy1000 »

You can probably use the smarty eval function, or the ProcessTemplateFromData function (available via search) to do that.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: how to include module call in UDT IF statement

Post 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.
Post Reply

Return to “CMSMS Core”