Jump to content

Injecting category names into product-list.tpl - SOLVED


Torbz

Recommended Posts

Hi folks,

I'm trying to inject the name of the sub-category to which a product belongs before the product name in product-list.tpl.

 

The current code is:

<h3>{if isset($product.new) && $product.new == 1}
<span class="new">{l s='New'}</span>{/if}
<a href="%7B$product.link%7Cescape:%27htmlall%27:%27UTF-8%27%7D" title="{$product.name|escape:'htmlall':'UTF-8'}">
[b]{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}[/b]</a></h3>

 

and I would imagine an addition like this:

 

<h3>{if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if}<a href="%7B$product.link%7Cescape:%27htmlall%27:%27UTF-8%27%7D" title="{$product.name|escape:'htmlall':'UTF-8'}">
[b]{$subcategory.name|escape:'htmlall':'UTF-8'}
{$product.name|truncate:35:'...'|escape:'htmlall':'UTF-8'}[/b]</a></h3>

 

would work.

 

I have to do this because the client's catalogue is arranged in such a way that his sub-categories are the artist name (he sells CD's) and the product names do not already include the artist.

 

I also need to do the same in the featured products module, as the album name appears here but not the artist name (the sub-category).

 

*EDIT*

 

Solved the first bit by inserting:

 

{strip}

{$category->name|escape:'htmlall':'UTF-8'}

{$categoryNameComplement|escape:'htmlall':'UTF-8'}

 

{/strip}

 

before the product name.

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...