Magento -自定义模块添加第二页


Magento - custom module add 2nd page

我已经为此工作了几天了,我已经为Magento创建了一个自定义模块来添加客户帐户页面,使用这个指南- http://alanstorm.com/magento_create_customer_page

所以我有www.mydomain.com/portfolio它指向自定义模块与以下代码从我的布局文件:

<portfolio_index_index>
            <update handle="customer_account" />
            <reference name="root">
                    <action method="setTemplate"><template>page/1column.phtml</template></action>
            </reference>
            <reference name="my.account.wrapper">
                <block type="core/template" name="cadaptor_portfolio_content" template="cadaptor_portfolio.phtml"/>           
            </reference>
</portfolio_index_index>

我现在正试图在www.mydomain.com/portfolio/add或类似的地方添加第二个页面到模块,实际的URL并不重要。

所以我把这个添加到布局文件中:

<action method="addLink">
    <name>portfolio_add</name>
    <path>portfolio/add</path>
    <label>Add To Your Portfolio</label>
</action>

工作得很好…链接出现在菜单&去它该去的地方。

亦添加:

<portfolio_add>
            <update handle="customer_account" />
            <reference name="root">
                    <action method="setTemplate"><template>page/1column.phtml</template></action>
            </reference>
            <reference name="my.account.wrapper">
                <block type="core/template" name="cadaptor_portfolio_add" template="cadaptor_portfolio_add.phtml"/>           
            </reference>
</portfolio_add>

我已经创建并上传了_add模板文件,但是除了404错误之外什么都得不到,如果有人能给我一个正确的方向,我会非常感激。

首先,添加页面的布局句柄应该是portfolio_index_add而不是portfolio_add
并在您的IndexController.php中添加以下方法:

public function addAction()
{
    $this->loadLayout();
    $this->renderLayout();
}

,路径应该是"portfolio/index/add"