I want to get current category ID in magento Footer area so that I can create a condition where certain things are not shown in that specific category. For example I want to do: if current category is 111 do not show the social icons
I tried the following code:
<?php$current_id= Mage::getModel('catalog/layer')->getCurrentCategory()->getId();echo $current_id;?>
Problem with the above code is that it echo a random ID and it doesnt change I go thru different categories.
Please help. Thank you.
To get current category details from registry:
$_category_detail=Mage::registry('current_category');
To get the category id:
$category_id= Mage::registry('current_category')->getId();
But you must not apply cache on the footer -- please refer to this stackexchange link.
When you don’t have access to $this, you can use Magento registry:
$category_id = Mage::registry('current_category')->getId();
OR
Get the variable set on the Block for xml
$this->getLayout()->getBlock('product_list')->getCategoryId()