Get category in summary template [Prodcuts]

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
jobmoving
New Member
New Member
Posts: 7
Joined: Tue May 10, 2011 9:20 pm

Get category in summary template [Prodcuts]

Post by jobmoving »

Hi there,

I'm trying to put the name of the category in the summary template.
I'm using the Products module.

I saw another post about this but it didn't help me.
http://forum.cmsmadesimple.org/viewtopi ... ry#p252563

Can anybody explain this to me?
Many thanks.

Gr. Job
scotch33
Dev Team Member
Dev Team Member
Posts: 284
Joined: Tue Feb 14, 2006 9:56 pm

Re: Get category in summary template [Prodcuts]

Post by scotch33 »

Ok - I had to try and do this too. the following solution is a bit hacky and a real coder will be able to give you a better way to do it I am sure, but as a simple trick, stick this at the top of your summary template - it simply grabs the first product on the page's category and sticks it at the top of the list.

{assign var='number' value=1}
{foreach from=$items item=entry}
{if isset($entry->categories)}<br />
{foreach from=$entry->categories item='category'}
{if $number == 1}
<h1>{$category->name}</h1>
{/if}
{assign var='number' value=2}
{/foreach}
{/if}
{/foreach}
Post Reply

Return to “Modules/Add-Ons”