我们有时候有一些业务上的需要,需要对不同的页面做一些判断调整,可以需要去判断当前的属于哪一种类型的页面
$router = $this->getRequest()->getRouteName().'_'.$this->getRequest()->getControllerName().'_'.$this->getRequest()->getActionName();
if($router=="cms_index_index"){//当前页是首页}
if($router=="catalog_category_view"){//当前页是分类列表页}
if($router=="catalog_product_view"){//产品详细页面}
判断是否为列表页
$router = $this->getRequest()->getRouteName().'_'.$this->getRequest()->getControllerName().'_'.$this->getRequest()->getActionName();
if($router=="catalog_category_view"){//当前页是分类列表页}
判断是否为产品页
$router = $this->getRequest()->getRouteName().'_'.$this->getRequest()->getControllerName().'_'.$this->getRequest()->getActionName();
if($router=="catalog_product_view"){//产品详细页面}
判断用户是否登录
if ($this->helper('customer')->isLoggedIn()) {
//判读当前用户是否登录
var_dump(Mage::getSingleton('customer/session')->isLoggedIn());
//用户登录则打印用户信息
}else{
echo '未登录';
}
大家有需要可以去测试…