Hi there!
I use the new version of CTLModuleMaker and I really like it! Great job!
I created a module with this structure:
Category -> Subcategory -> Products
What I would like to have is a template which lists all Products but grouped by Subcategory. E.g.
Subcategory 1
Product 1
Product 2
Subcategory 2
Product 1
Product 2
Product 3
Is this possible?
Best,
Markus
CTLModuleMaker -> Display Products by Group
Re: CTLModuleMaker -> Display Products by Group
Yes.
create the template "list_products" :
and the template "list_subcategories" :
then in your page call the subcategories with the appropriate template :
{cms_module module="modulename" what="subcategory" listtemplate="list_subcategories"}
(of course, make sure the names of the module and levels are correct)
(you could repeat the logic to include the categories in the list)
If you created your module using a recent version of CTLModuleMaker, you should think about using the "sitemap" action, which is made to output a cross-level list (it does so in only one query, and as such is quite faster when you have a lot of levels/items), although it allows less customization.
Pierre-Luc
create the template "list_products" :
Code: Select all
<ul>
{foreach from=$itemlist item="item"}
<li>{$item->detaillink} (or {$item->name} if you prefer)</li>
{/foreach}
</ul>
Code: Select all
<ul>
{foreach from=$itemlist item="item"}
<li>{$item->name}{cms_module module="modulename" what="product" listtemplate="list_products" forcelist="1"}</li>
{/foreach}
</ul>
{cms_module module="modulename" what="subcategory" listtemplate="list_subcategories"}
(of course, make sure the names of the module and levels are correct)
(you could repeat the logic to include the categories in the list)
If you created your module using a recent version of CTLModuleMaker, you should think about using the "sitemap" action, which is made to output a cross-level list (it does so in only one query, and as such is quite faster when you have a lot of levels/items), although it allows less customization.
Pierre-Luc
Re: CTLModuleMaker -> Display Products by Group
Hi, I'm trying to achieve the same thing but can't get it to work.
I've made a curriculum vitae builder.
First you add a section header (e.g. personalia/hobbies/work experience)
Then you can add a detail, which has to fields:
- label (e.g. birth date)
- detail (e.g. April 21 1983)
On my page I would like to display the following:
Personalia
Birth date: April 21 1983
Birth place: Cape-Town
Work experience
2000-2005: Photoshop expert
2005-2009: Chillin
etc. etc.
At the moment I'm getting the wrong output, namely:
Personalia
Birth date: April 21 1983
Birth place: Cape-Town
2000-2005: Photoshop expert
2005-2009: Chillin
Work experience
Birth date: April 21 1983
Birth place: Cape-Town
2000-2005: Photoshop expert
2005-2009: Chillin
As you can see, the headings display correctly, but the labels and details are being repeated.
I'm calling the module in the page template like this:
My headings template is:
And the details template is:
So, what am I doing wrong?
Home you can help.
I've made a curriculum vitae builder.
First you add a section header (e.g. personalia/hobbies/work experience)
Then you can add a detail, which has to fields:
- label (e.g. birth date)
- detail (e.g. April 21 1983)
On my page I would like to display the following:
Personalia
Birth date: April 21 1983
Birth place: Cape-Town
Work experience
2000-2005: Photoshop expert
2005-2009: Chillin
etc. etc.
At the moment I'm getting the wrong output, namely:
Personalia
Birth date: April 21 1983
Birth place: Cape-Town
2000-2005: Photoshop expert
2005-2009: Chillin
Work experience
Birth date: April 21 1983
Birth place: Cape-Town
2000-2005: Photoshop expert
2005-2009: Chillin
As you can see, the headings display correctly, but the labels and details are being repeated.
I'm calling the module in the page template like this:
Code: Select all
{cms_module module="cvbuilder" what="heading" listtemplate="heading"}Code: Select all
{foreach from=$itemlist item="item"}
<div class="cv_category">
<h3>{$item->name}</h3>
<table>
<tbody>
{cms_module module="cvbuilder" what="detail" listtemplate="list_default"}
</tbody>
</table>
</div>
{/foreach}
Code: Select all
{foreach from=$itemlist item="item"}
<tr>
<td><span>{$item->label}</span></td>
<td>{$item->detail}</td>
</tr>
{/foreach}
Home you can help.
Re: CTLModuleMaker -> Display Products by Group
Headings template should be :
But for performance reasons, I would suggest using the solution shown in the FAQ :
Create the following template (which I'll call "order_by_parents"):
and call it using {cms_module module="cvbuilder" what="detail" listtemplate="order_by_parents" orderby="parent"}
Code: Select all
{foreach from=$itemlist item="item"}
<div class="cv_category">
<h3>{$item->name}</h3>
<table>
<tbody>
{cms_module module="cvbuilder" what="detail" listtemplate="list_default" parent=$item->alias}
</tbody>
</table>
</div>
{/foreach}
Create the following template (which I'll call "order_by_parents"):
Code: Select all
<ul>
{assign var="parentflag" value=false}
{foreach from=$itemlist item="item"}
{if $item->parent_name != $parentflag}
{if $parentflag}</ul></li>{/if}
<li>{$item->parent_name}<ul>
{assign var="parentflag" value=$item->parent_name}
{/if}
<li>{$item->label}: {$item->detail}</li>
{/foreach}
</ul>Re: CTLModuleMaker -> Display Products by Group
Thanks! it works great!
However, the sorting isn't working. I would like the order of the headings and the items to be determined by the order in the admin (with ordering arrows).
How would I do this? since the orderby param is already used?
However, the sorting isn't working. I would like the order of the headings and the items to be determined by the order in the admin (with ordering arrows).
How would I do this? since the orderby param is already used?
Re: CTLModuleMaker -> Display Products by Group
I've just looking at my code again and noticed that if you leave the orderby parameter empty, it should behave the way you want it.
Try it out, and if it doesn't work I'll show you another solution.
plger
Code: Select all
{cms_module module="cvbuilder" what="detail" listtemplate="order_by_parents"}plger

