如果在PHP中为Magento网站声明,则需要隐藏在主页,结帐和成功页面上

时间:2016-04-29 01:04:05

标签: php magento if-statement

这是目前正在使用的不在主页上显示的内容。并在所有其他页面上显示,需要帮助不显示/ checkout / cart /和/ onepage /和onepage / successs。

<?php if(Mage::getBlockSingleton('page/html_header')->getIsHomePage()): ?>
<?php else: ?>

(Div I am trying to display only on pages other than homepage,checkout,success)

<?php endif; ?>

2 个答案:

答案 0 :(得分:1)

请试试这个

$routeName = Mage::app()->getRequest()->getRouteName();
$identifier = Mage::getSingleton('cms/page')->getIdentifier();

if($routeName == 'cms' && $identifier == 'home') {
    echo 'This is Magento Homepage.';
} else {
    echo 'This is not a Magento Homepage.';
}

这应该仅适用于主页。要隐藏在多个页面上,您可以创建一个页面数组并检查其中是否存在路径名称

谢谢

答案 1 :(得分:0)

将以下代码放在头文件中。

主页:

<?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';}

用于单页结帐页面:

if($pageIdentifier == 'aw_onestepcheckout_index_index'){echo 'this is checkout page';}

订单成功页面:

if($pageIdentifier == 'checkout_onepage_success'){echo 'this is sucess page';}

使用此代码,您可以获得其他页面标识并根据需要使用。

希望这会奏效。