can I add a criteria to a module?
I wanna add criterias to a module in the themehooks file.
I've tried a lot of method, but still didn't find out.
for example:
{module name="PromotedContentModule" Selector="role" ContentType="discussions" Selection="administrator" Limit="3" BodyLimit="90"}
I need to add above criterias to the following function:
public function discussionController_BeforeFirstComment_handler($Sender) { // $PromotedContentModule = new PromotedContentModule(); echo $PromotedContentModule->toString(); }
Best Answer
-
R_J Admin
Great question!
The {module... syntax is a custom Smarty function. If you look it up you will find that it points towards class Theme, method module. In that method you will find the following code
$Properties = array_merge($ControllerProperties, $Properties); foreach ($Properties as $Name => $value) { // Check for a setter method if (method_exists($Module, $method = 'set'.ucfirst($Name))) { $Module->$method($value); } else { $Module->$Name = $value; } }
Without further testing, I would expect that in your example
{module name="PromotedContentModule" Selector="role" ContentType="discussions" Selection="administrator" Limit="3" BodyLimit="90"}
you would need a module which implemets the following methods:- setSelector
- setContentType
- setSelection
- setLimit
- setBodyLimit
If that methods are not implemented, you should be able to access the values directly as properties of your module.
Oh wait, your question has been the other way around. But then it is just the other way around:
public function discussionController_beforeFirstComment_handler($sender) { $promotedContentModule = new PromotedContentModule($sender); if (method_exists('setSelector')) { $promotedContentModule->setSelector('role'); } else { $promotedContentModule->Selector = 'role'; } //Repeat for every parameter... echo $promotedContentModule->toString(); }
2
Answers
Great question!
The {module... syntax is a custom Smarty function. If you look it up you will find that it points towards class Theme, method module. In that method you will find the following code
Without further testing, I would expect that in your example
{module name="PromotedContentModule" Selector="role" ContentType="discussions" Selection="administrator" Limit="3" BodyLimit="90"}
you would need a module which implemets the following methods:If that methods are not implemented, you should be able to access the values directly as properties of your module.
Oh wait, your question has been the other way around. But then it is just the other way around:
Thank you again
Awesome support