在header.phtml里面怎么判断当前页面是产品详情页?

在header.phtml里面怎么判断当前页面是产品详情页?

有很多种方法,每种方式我演示一次,总有一款符合你的需求:
##判断当前页面是产品页面

//这也是你最想要的效果
if(Mage::registry('current_product')) 
{
  // Product detail page
}

##判断当前页面是购物车页面

$request = $this->getRequest();
$module = $request->getModuleName();
$controller = $request->getControllerName();
$action = $request->getActionName();
if($module == 'checkout' && $controller == 'cart' && $action == 'index')
{
  //Cart Page
}

##判断当前页面是可配置产品页面

if(Mage::app()->getFrontController()->getRequest()->getRequestedActionName() == 'configure')
{
// Product Configuration page
}

##判断当前页面是CMS页面

if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')
{
  echo Mage::getSingleton('cms/page')->getIdentifier();
}
<?php //if(Mage::registry('current_product')):?> <?php //echo ?> <?php //endif;?>

没用

你这代码有问题,肯定不能用了.而且上面我给出了多种方法判断,一个不行就试另外一个.