So i am trying to display a custom list.phtml file from within a block.
thats fine i am able to display all the products with category id 6.
{{block type="catalog/product_list" category_id="6" template="catalog/product/list.phtml"}}
the above works fine. But now i want to get access to category id 6’s name, how would i go about doing this from within list.phtml or even from within a different block. i just need the name of the category for the id =6 .
Inside the list.phtml block template you can get the category name with
In this case the current category is set on the layer by the
catalog/product_listblock in the_getProductCollection()call.Inside the CMS page content there is no way I know of to access the category name directly.
From a different block getting the category name might be more involved. You can try
Of course it might be the case that there is no current category might set on the layer instance, so make sure to check for that to avoid ugly errors.
Basically, if the
catalog/product_listproduct list block’s_beforeToHtml()method has been executed the current category will be set on the layer.EDIT:
All this is assuming you want to get the category name without specifying the category ID again. If you don’t care about that you can always get the category name with