2014-12-05 105 views
1

我想在magento Footer區域中獲取當前類別ID,以便創建一個條件,其中某些內容不會顯示在該特定類別中。比如我想做的事: 如果目前的類別是111 不顯示社交圖標獲取Magento Footer中的類別ID

我嘗試下面的代碼:

<?php$current_id= Mage::getModel('catalog/layer')->getCurrentCategory()->getId();echo $current_id;?> 

問題與上面的代碼是,它呼應隨機ID和它不會改變我通過不同的類別。

請幫忙。 謝謝。

+0

你有沒有嘗試一下?法師::註冊表( 'current_category') – 2014-12-05 18:15:19

回答

0

從註冊表獲得當前類別的詳細信息:

$_category_detail=Mage::registry('current_category'); 

要獲得類別ID:

$category_id= Mage::registry('current_category')->getId(); 

但你不應該在頁腳應用緩存 - 請參閱本stackexchange link

4

當你沒有獲得$這一點,你可以使用Magento的註冊表:

$category_id = Mage::registry('current_category')->getId(); 

OR

獲取變量集上的阻止對XML

$this->getLayout()->getBlock('product_list')->getCategoryId()