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
[SOLVED]Summary and Detail pages in modules
[SOLVED]Summary and Detail pages in modules
Last edited by jissey on Sun Sep 27, 2015 4:02 pm, edited 1 time in total.
Re: Summary and Detail pages in modules
Yes I could reproduce this.
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, by
HTH
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.jissey wrote:$smarty->assign('items', $items);
echo $this->ProcessTemplateFromDatabase($summarytemplate);
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();
Code: Select all
$smarty = $this->GetActionTemplateObject();
"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!
* 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!
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Summary and Detail pages in modules
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.
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.
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.
Re: Summary and Detail pages in modules
with 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
Code: Select all
$smarty = $this->GetActionTemplateObject();
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
Re: Summary and Detail pages in modules
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!
* 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!
Re: Summary and Detail pages in modules
That's ok now.
thx
thx