Page 1 of 1

[SOLVED] CTLModuleMaker: total number of products in the cat

Posted: Mon Mar 31, 2014 2:10 pm
by Doodeen
I created a module using CTLModuleMaker 2.0.4.
Structure of categories:

-brand
--model (with a dropdown field "brand")

-unit
--parts (with a dropdown field "unit")

---part (with a dropdown field "parts" and the field Select "model")

List of units and parts - the same for all models.

Module call:
{cms_module module = "my_module" what = "brand" orderby = "name"}

list template is default_list.

brand_detail template:
{$item=$itemlist[0]}{$item}</br>
{cms_module module="my_module" what="model" where_brand=$item->id->value}

and so on...

  how to get the total number of leaf-level products (part) in the category of any level?
For example:
> brand1 (7)
> brand2 (2)
> brand3 (0)

then:

brand1
>model1 (2)
>model2 (1)
>model3 (4) and so on...

And another thing: how to make breadcrumbs in this module?

Can anybody help? =\

Re: CTLModuleMaker: total number of products in the category

Posted: Thu Apr 03, 2014 6:18 am
by Doodeen
I solved the problem by UDT like this:
for brands

global $gCms;
$db =& $gCms->Getdb();

$query = "SELECT * FROM (cms_module_myModule_brand INNER JOIN cms_module_myModule_model ON cms_module_myModule_brand.id = cms_module_myModule_model.parent) INNER JOIN cms_module_myModule_part ON cms_module_myModule_model.id = cms_module_myModule_part.model WHERE (cms_module_myModule_brand.id)= ? AND cms_module_myModule_part.active = '1' ";

$dbresult = $db->Execute($query, array('cms_module_myModule_brand.id'=>$params['id']));

if(!$dbresult) {
echo "DB Error: " . $db->ErrorMsg();
} else
echo $dbresult->RecordCount();

Re: [SOLVED] CTLModuleMaker: total number of products in the

Posted: Thu Apr 03, 2014 7:11 am
by chandra
Use

$gCms = cmsms() ;

instead

global $gCms ;

;)

Re: [SOLVED] CTLModuleMaker: total number of products in the

Posted: Thu Apr 03, 2014 7:29 am
by Rolf
chandra wrote:Use

$gCms = cmsms() ;

instead

global $gCms ;

;)
Even better:

Code: Select all

$db = cmsms()->GetDb();

Re: [SOLVED] CTLModuleMaker: total number of products in the

Posted: Thu Apr 03, 2014 8:47 am
by Doodeen
Thanks, I'll use.