我已将类别页面设置为我的默认主页。但是现在我想显示CMS (Home page)
未登录用户登录时我想显示类别页面。我可以设置如何设置逻辑加载两个cms页面。我怎样才能做到这一点 ?感谢您提前提供任何帮助
<?php if(!Mage::getSingleton('customer/session')->isLoggedIn()): ?>
load->category page
<?php else: ?>//If user is NOT logged in
Load home page default one
<?php endif; ?>
答案 0 :(得分:1)
如果你只想检查主页上的条件。你可以这样做。改变CMS控制器的一点代码:
class Mage_Cms_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction($coreRoute = null)
{
if(Mage::getSingleton('customer/session')->isLoggedIn())
{
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('catalog/category/view/id/3'));
}else{
$pageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE);
if (!Mage::helper('cms/page')->renderPage($this, $pageId)) {
$this->_forward('defaultIndex');
}
}
}
尝试告诉我结果。希望这可以解决您的问题
答案 1 :(得分:0)
这可能适用于您的情况:
//条件取决于用户的登录状态
if(!$this->helper('customer')->isLoggedIn())
{
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl());
die();
}
else
{
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('YOUR_CATEGORY_URL'));
die();
}
IF above doesn't work, try this :
$sessionCustomer = Mage::getSingleton("customer/session");
if($sessionCustomer->isLoggedIn()) {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('YOUR_CATEGORY_URL'));
} else {
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getBaseUrl());
}