Page 1 of 1

How to get in summary template category name?

Posted: Tue Apr 19, 2011 1:44 pm
by seregarem
I need to get the category name in a summary template. Get_template_vars gives me:

Code: Select all

...
module_message = 
image = Object
gcb_params = Array (1)
returnid = 60
actionid = cntnt01
actionparams = Array (6)
Products = Object
items = Array (20)
totalcount = 20
pagetext = Страница
oftext = Из
pagecount = 1
curpage = 1
firstlink = <<
prevlink = <
lastlink = >>
nextlink = >
currency_symbol = $
weight_units = lbs
So, I can work only with $items, but I need to get Category name.
Thire is $Products, but how to get exactly parent (Category name) of the $items.
And in categorylist I need to get products in some category, but there is only $categorylist.
How to get? Please, help!!!

Re: How to get in summary template category name?

Posted: Thu Apr 21, 2011 2:04 pm
by pixelita
Is this for the Products module (e-commerce)? This should be moved to third-party module support in that case.

And have this in my summary template, is this what you mean? (My next goal is to make that clickable, but not at that stage of the project yet.)

Code: Select all

{if isset($entry->categories)}<br /> 
<strong>Categories:</strong> 
{foreach from=$entry->categories item='category'} {$category->name}, 
{/foreach}
{/if} 
Wait a minute! What do you mean "exact parent"? Are you sure you mean category and not hierarchy?

Re: How to get in summary template category name?

Posted: Fri Apr 22, 2011 2:28 pm
by seregarem
I use this summary template:

Code: Select all

<div class="track">
<h2>Popular clips</h2>
{if isset($pagecount) && $pagecount gt 1}
<div id="pagination">
{$firstlink} {$prevlink} {$pagetext} {$curpage} {$oftext} {$pagecount} {$nextlink} {$lastlink}
</div>
{/if}
<ul class="topics">
{foreach from=$items item=entry}
{assign var="id_track" value=$entry->id}
{category_name}
<li>
<h5>{$category_name}<span> - {$entry->product_name}</span></h5>

{if isset($entry->fields.photo)&& !empty($entry->fields.photo->value)}
  <a href="{$entry->detail_url}"><img src="{$entry->file_location}/{$entry->fields.photo->value}" alt="{$entry->product_name}"/></a>
{else}
<a href="{$entry->detail_url}"><img src="images/default.jpg" alt="{$entry->product_name}"/></a>
{/if}

<p><a href="{$entry->detail_url}" class="link2">Watch</a>
<span>Added: {$entry->create_date|date_format:"%d %B %Y"}</span>
{if $entry->price ne ''}
<span>Просмотров: {$entry->price}</span>
{/if}
</p>

</li>
{/foreach}
</ul>
{if isset($pagecount) && $pagecount gt 1}
<div id="pagination">
{$firstlink} {$prevlink} {$pagetext} {$curpage} {$oftext} {$pagecount} {$nextlink} {$lastlink}
</div>
{/if}
</div>
I have to use an user tag {category_name}, where I get a category (an artist).

There is no $entry->categories. I use the structure:
1. Category - Artist (ex. T.I.)
a. Product - Clip
b. Product - Clip
c. Product - Clip
2. Category - Artist (ex. Akon)
a. Product - Clip
b. Product - Clip
c. Product - Clip
And so on.