How can I change page template from a module?

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
jatinder
Forum Members
Forum Members
Posts: 17
Joined: Thu Apr 12, 2007 1:49 pm

How can I change page template from a module?

Post 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
Vin

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

Post by Vin »

Wouldn't changing CSS suffice?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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}
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.
jatinder
Forum Members
Forum Members
Posts: 17
Joined: Thu Apr 12, 2007 1:49 pm

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

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

Return to “CMSMS Core”