[SOLVED]Summary and Detail pages in modules

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
User avatar
jissey
Forum Members
Forum Members
Posts: 61
Joined: Sun Jul 18, 2010 12:17 pm
Location: South of France

[SOLVED]Summary and Detail pages in modules

Post by jissey »

Hello,
I'm working on EasyList.
With CMSMS 2.0 version, the default action summary works good but not the detail page (like in News module).
With SVN 2.0.1 version, the default action display nothing.
The php variable is not passed to the template :
$smarty->assign('items', $items);
echo $this->ProcessTemplateFromDatabase($summarytemplate);
In the template the smarty variable {$items} is empty.

What modification should I make between 2.0 and 2.0.1 version?

Thx
Last edited by jissey on Sun Sep 27, 2015 4:02 pm, edited 1 time in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: Summary and Detail pages in modules

Post by Jo Morg »

Yes I could reproduce this.
jissey wrote:$smarty->assign('items', $items);
echo $this->ProcessTemplateFromDatabase($summarytemplate);
Because of Smarty variable scope issues we were experiencing there were some changes made to CMSMS Smarty implementation. In most modules, where $smarty is already in scope inside the action method/files $this->ProcessTemplateFromDatabase() should work fine, but when a module overrides the DoAction() method of the CMSModule class, $smarty = cmsms()->GetSmarty() returns the global $smarty object instead of the current used template object so assigned variables will be out of current template scope.
On these cases, and following a Calguy1000 suggestion, I tested using a new (CMSMS 2.0.1+) module API method that returns the correct Smarty template object: $this->GetActionTemplateObject()...
So I would replace, where you override the CMSModule DoAction,

Code: Select all

$smarty = cmsms()->GetSmarty();
by

Code: Select all

$smarty = $this->GetActionTemplateObject();
HTH
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Summary and Detail pages in modules

Post by calguy1000 »

Just to follow up:

As of CMSMS 2.0.1:

For module action files (action.whatever.php) the correct smarty template object is available in scope as the $smarty variable. $this->ProcessTemplate(), and $this->ProcessTemplateFromDatabase() will work correctly.

Note: Those methods are deprecated.

If you feel you absolutely must use the global smarty object (usually you do not need to do this). Then you must call the fetch method on it yourself.

This change, and others were made because of a problem reported in 2.0 where a variable created in a parent template was not properly available in a child template.
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.
User avatar
jissey
Forum Members
Forum Members
Posts: 61
Joined: Sun Jul 18, 2010 12:17 pm
Location: South of France

Re: Summary and Detail pages in modules

Post by jissey »

with

Code: Select all

$smarty = $this->GetActionTemplateObject();
it works but there is a warning :
Warning: Parameter 2 to SmartyBC::assign_by_ref() expected to be a reference, value given in lib\smarty\sysplugins\smarty_internal_templatebase.php on line 773
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1967
Joined: Mon Jan 29, 2007 4:47 pm

Re: Summary and Detail pages in modules

Post by Jo Morg »

Replace all $smarty->assign_by_ref() with $smarty->assign(). There is no need to assign by reference anymore.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
jissey
Forum Members
Forum Members
Posts: 61
Joined: Sun Jul 18, 2010 12:17 pm
Location: South of France

Re: Summary and Detail pages in modules

Post by jissey »

That's ok now.
thx
Locked

Return to “Modules/Add-Ons”