將代碼放置在您的頭文件中。
的主頁:
<?php if ($this->getIsHomePage()){echo 'this is home page';}else{echo 'this is not home page';}
現在我們將採取一個變量$ pageIdentifier其他然後主頁
<?php $pageIdentifier = Mage::app()->getFrontController()->getAction()->getFullActionName();?> /* this identifier value will change as per page.so echo this variable so you will get page identifier on all pages*/
的購物車頁面:
if($pageIdentifier == 'checkout_cart_index'){echo 'this is cart page';}
爲onepage結帳頁面:
if($pageIdentifier == 'aw_onestepcheckout_index_index'){echo 'this is checkout page';}
訂單sucess頁:
if($pageIdentifier == 'checkout_onepage_success'){echo 'this is sucess page';}
使用此代碼,你可以得到其他頁面的身份,並根據自己的需要使用。
希望這會起作用。
你在哪個文件中使用了這些代碼?這應該只在頭文件中工作,並檢入任何文件,您可以使用 $ routeName = Mage :: app() - > getRequest() - > getRouteName(); $ identifier = Mage :: getSingleton('cms/page') - > getIdentifier(); if($ routeName =='cms'&& $ identifier =='home'){ echo'這是Magento主頁。'; } else { echo'這不是Magento主頁。'; } –