Page 1 of 1

returning data from custom module through Smarty

Posted: Wed Sep 19, 2012 1:21 pm
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