returning data from custom module through Smarty

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
otsakir
Forum Members
Forum Members
Posts: 17
Joined: Wed Mar 07, 2012 4:26 pm

returning data from custom module through Smarty

Post by otsakir »

Hello,

I am working on an custom module that adds some functionality to Products. I have written an action that retrieves some product ids and returns them as an array variable to the calling template through Smarty. The name of the array variable is passed through the 'assign' module parameter. The problem is that the variable is always empty after the module's action invocation.

Here is the excerpt from the template that uses the module (actually, it is somewhere inside the Products's detail teamplate):

Code: Select all

...
<dd>{cms_module module="Inventory" action="productsbygroup" groupid=$entry->fields.colorgroup->value groupfield="colorgroup" assign="product_ids"}  product_ids: {$product_ids|print_r} </dd>
...
here, when print_r()ing $product_ids nothing comes up.

and here is the part of the module's action that returns the array through smarty:

Code: Select all

...
$product_ids = $db -> GetCol ($query, array($params['groupfield'], $params['groupid']));
			
if ( count($product_ids) )
{
	$smarty -> assign ($params['assign'], $product_ids);
} else
	return;
...
I have also checked the value of $params['assign'] and it is ok.

Is there any other way to pass data from a module's action to the template that invokes this action ?

P.S. cmsms version 1.11.1
Post Reply

Return to “Developers Discussion”