Url Magento 1.5.1:新客户仪表板模块
我正在尝试在我的客户仪表板上创建一个新的非常简单的部分。类似于www.mymagentosite.com/customer/rid(rid只包括静态链接)。但是,当我尝试访问www.mymagentosite.com/customer/rid时,我总是会看到404 Magento页面(日志文件中没有异常或系统消息) 我错过了什么 多谢各位 到目前为止,我所做的是: -在/app/code/local/Mage/Customer/Block/Account/Dashboard/Rid.php下创建一个新块Url Magento 1.5.1:新客户仪表板模块,url,magento,mapping,block,Url,Magento,Mapping,Block,我正在尝试在我的客户仪表板上创建一个新的非常简单的部分。类似于www.mymagentosite.com/customer/rid(rid只包括静态链接)。但是,当我尝试访问www.mymagentosite.com/customer/rid时,我总是会看到404 Magento页面(日志文件中没有异常或系统消息) 我错过了什么 多谢各位 到目前为止,我所做的是: -在/app/code/local/Mage/Customer/Block/Account/Dashboard/Rid.php下创建
class Mage_Customer_Block_Account_Dashboard_Rid extends Mage_Core_Block_Template
{
public function getCustomer()
{
return Mage::getSingleton('customer/session')->getCustomer();
}
}
-在/app/code/local/Mage/Customer/controllers/RidController.php下创建一个新控制器
class Mage_Customer_RidController extends Mage_Core_Controller_Front_Action
{
protected function _getSession()
{
return Mage::getSingleton('customer/session');
}
public function preDispatch()
{
parent::preDispatch();
if (!Mage::getSingleton('customer/session')->authenticate($this)) {
$this->setFlag('', 'no-dispatch', true);
}
}
public function indexAction()
{
if (count($this->_getSession()->getCustomer()->getAddresses())) {
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('catalog/session');
$block = $this->getLayout()->getBlock('rid');
if ($block) {
$block->setRefererUrl($this->_getRefererUrl());
}
$this->renderLayout();
} else {
$this->getResponse()->setRedirect(Mage::getUrl('*/*/new'));
}
}
}
-在/app/code/local/Mage/Customer/helper/Rid.php下创建一个新的助手
class Mage_Customer_Helper_Rid extends Mage_Core_Helper_Abstract
{
public function getRenderer($renderer)
{
if(is_string($renderer) && $className = Mage::getConfig()->getBlockClassName($renderer)) {
return new $className();
} else {
return $renderer;
}
}
}
-编辑文件/app/design/frontend/default/MYTHEME/layout/customer.xml
<customer_account_index translate="label">
<label>Customer My Account Dashboard</label>
<update handle="customer_account"/>
<!-- EXISTING CODE -->
<reference name="my.account.wrapper">
<!-- EXISTING CODE -->
<block type="customer/account_dashboard_rid" name="rid" as="rid"
template="customer/account/dashboard/rid.phtml"></block>
</block>
</reference>
</customer_account_index>
<customer_rid_index translate="label">
<label>RID</label>
<!-- Mage_Customer -->
<update handle="customer_account"/>
<reference name="my.account.wrapper">
<block type="customer/rid" name="address_book"
template="customer/account/dashboard/rid.phtml"/>
</reference>
</customer_rid_index>
客户我的帐户仪表板
摆脱
-创建/app/design/frontend/default/MYTHEME/template/customer/account/dashboard/rid.phtml您需要告诉Magento使用您的控制器,而不是核心: “这里需要注意的一个重要问题是,对于控制器,Magento不会像对块和模型那样自动加载它们。” etc/config.xml
<config>
<frontend>
<routers>
<checkout>
<args>
<modules>
<My_Module before="Mage_Checkout">My_Module_Checkout</My_Module>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>
我的模块结账
请粘贴您的config.xml,这是解决您的问题最有趣的一个。hi@osdave,我没有碰config.xml。这是您可以在基本安装中找到的标准config.xml。我应该换哪一部分?谢谢你的帮助!对不起,oups没有看到您没有创建模块,而是对核心进行了黑客攻击(您确实不应该这样做)。我复制了你的代码,它在这里工作得很好。缓存可能吗?@OSdave,我在“本地”中创建了所有新代码,所以我没有真正入侵核心。只是走了一小段路(或者我就是这么想的)。那么,您是说您只编辑/创建了我列出的文件,如果您键入/customer/rid,它将显示实际页面?你接触过其他XML吗?缓存(不幸的是)似乎不是我这边问题/解决方案的一部分。还有其他想法吗?