Jump to content

Get Parent categories in product-list.tpl


Annacvl

Recommended Posts

Hi! I Want to be able to show under the product list related categories.(In this case parent categories from my shop)
I've been able to show Subcategories -and itworked. (I'll leave the code in the end)
And I found this code, which i think it may be really close to make it work but is not really working....

{assign var='category' value=Category::getCategories(Context::getContext()->language->id)}

{foreach from=Category::getCategories(Context::getContext()->language->id) item=cat} 
    <a href="#">{$category['name']}</a>
 {/foreach}
<pre>{$category|@print_r}</pre>
 

Any suggestions? This is the code I use for subcategories
 

		{if isset($subcategories)}
        {if (isset($display_subcategories) && $display_subcategories eq 1) || !isset($display_subcategories) }
		<!-- Subcategories -->
		<div id="subcategories">
			<p class="subcategory-heading">{l s='Subcategories'}</p>
			<ul class="clearfix">
			{foreach from=$subcategories item=subcategory}
				<li>
                	<div class="subcategory-image">
						<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}" title="{$subcategory.name|escape:'html':'UTF-8'}" class="img">
						{if $subcategory.id_image}
							<img class="replace-2x" src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'category_default')|escape:'html':'UTF-8'}" alt="{$subcategory.name|escape:'html':'UTF-8'}"  />
						{else}
							<img class="replace-2x" src="{$img_cat_dir}{$lang_iso}-default-category_default.jpg" alt="{$subcategory.name|escape:'html':'UTF-8'}"  />
						{/if}
					</a>
                   	</div>
					<h5><a class="subcategory-name" href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}">{$subcategory.name|truncate:25:'...'|escape:'html':'UTF-8'}</a></h5>

				</li>
			{/foreach}
			</ul>
		</div>
        {/if}
		{/if}

Thanks!
 

Link to comment
Share on other sites

  • 3 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...