Page 1 of 1

call a module via udt

Posted: Mon Jan 28, 2013 10:14 am
by pistols
Hello There, I would like to encapsulate some logic into udt. so I can keep a simple template.

I have a condition. If the condition is true I want to show an image
If not i want to show a module (showtime)

So i have this

$gCms = cmsms();
$contentops = $gCms->GetContentOperations();
$content_obj = $contentops->getContentObject();
if (!is_object($content_obj)) {return;}

if (file_exists($content_obj->Alias().".jpg")) {
$smarty->assign('picture', '<img src="tick.jpg" alt="" />');
} else {
//Here I need help
//Call module Showtime with parameter 1 in smarty
//{Showtime show='1'}
}

So bottom line is, I don't know how to call a module within an udt

Thanks
Nikolas

Re: call a module via udt

Posted: Mon Jan 28, 2013 4:54 pm
by Rolf
Just wondering why you use a UDT for this and don't use Smarty in your page or template...
Something like:

Code: Select all

{if $foo == $bar}
<img src="" />
{else}
{Showtime}
{/if}

Re: call a module via udt

Posted: Mon Jan 28, 2013 8:05 pm
by pistols
Hello Rolf,

Well the main reason is because the logic behind finding that image file is a little bit more complicated. Currently i have a solution similar to the one you are suggesting, but i would like to call only my udt in the template.

Nikolas

Re: call a module via udt

Posted: Mon Jan 28, 2013 10:17 pm
by calguy1000
something like this:

Code: Select all

$module = cms_utils::get_module('ShowTime');
if( is_object($module) ) {
   $out = $module->DoAction('cntnt01','default',$parameters,$current_page_id);
}