Page 1 of 1

Two Detail Template Instances on One Page

Posted: Sun Oct 20, 2013 3:24 pm
by jskphotography
I've spent most of my afternoon trying to figure out how to overcome a detail template conflict I'm experiencing. I have a single page where I call a detail template from two different modules (News & CompanyDirectory). Both modules use the 'entry' Smarty object in the detail template and therefore the later module (CompanyDirectory) will not show.

Because the detailed templates are being called directly without the smarty object being 'inherited' from a previous summary template instance is there a way of deconflicting this? I thought there maybe a way of 'closing' or clearing Smarty objects in the first module before displaying the second.

I hope this is clear to understand and many help for any guidance

Re: Two Detail Template Instances on One Page

Posted: Sun Oct 20, 2013 3:29 pm
by calguy1000
Smarty (in CMSMS) has a single global scope. A variable can be overwritten multiple times.

if module A: creates the $entry variable, and module B: creates the $entry variable, and you need the one from module A after module B is called then you need to 'copy' the data from module A to a new name.

This usually happens when one module is called from within another.

i.e: In the CompanyDirectory detail template, calling News..
Solution: copy the $entry variable before calling News.

{$myvar=$entry}
{* now I can use $myvar->foo} where I would've used {$entry->foo} *}

[solved] Two Detail Template Instances on One Page

Posted: Sun Oct 20, 2013 6:11 pm
by jskphotography
I'm kicking myself and slightly embarrassed! Many thanks for pointing out the obvious...