Page 1 of 1

How can I change page template from a module?

Posted: Wed Apr 25, 2007 2:23 pm
by jatinder
Hello,

Is it possible to change the page template from a module's action file?

Suppose I have a page products.html in which I have embedded a custom module "Products". Now, is it possible to change the page template from a module's action file. That is, the page will have different templates based on different actions called.

Thanks,
Jatinder

Re: How can I change page template from a module?

Posted: Wed Apr 25, 2007 2:40 pm
by Vin
Wouldn't changing CSS suffice?

Re: How can I change page template from a module?

Posted: Wed Apr 25, 2007 2:45 pm
by calguy1000
No, you can't change the page template, however your module can export smarty variables via

Code: Select all

$smarty->assign('foo','bar' );
that you can later test for in your template logic.

i.e:  if your template has a call in it.

Then in your page, you can embed

Code: Select all

{cms_module module='mymodule' mode='blah'} 
that has the code above in it.

Then later in your template, you can something like this

Code: Select all

{if isset($foo) && $foo == 'bar' }
    {* don't include search, if the foo variable is set *}
{else}
    {search}
{/if}

Re: How can I change page template from a module?

Posted: Wed Apr 25, 2007 5:09 pm
by jatinder
Thanks for the replies, but I have managed to solve the problem on my own.

It involves passing the "showtemplate" parameter from the module. If the value of this parameter is "false", CMSMS will not use the template associated with the page. Then I can echo any output I want from the module.

Can anyone suggest a better solution?