Two Detail Template Instances on One Page

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
jskphotography
New Member
New Member
Posts: 3
Joined: Sun Oct 20, 2013 3:14 pm

Two Detail Template Instances on One Page

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

Re: Two Detail Template Instances on One Page

Post 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} *}
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.
jskphotography
New Member
New Member
Posts: 3
Joined: Sun Oct 20, 2013 3:14 pm

[solved] Two Detail Template Instances on One Page

Post by jskphotography »

I'm kicking myself and slightly embarrassed! Many thanks for pointing out the obvious...
Post Reply

Return to “CMSMS Core”