Ben
Ben

Reputation: 171

Magento - custom module add 2nd page

I've been working on this for days now, I've created a custom module for Magento to add a customer account page using this guide - http://alanstorm.com/magento_create_customer_page

So i've got www.mydomain.com/portfolio which points to the custom module with this code from my layout file:

<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>

I'm now trying to add a second page to the module at www.mydomain.com/portfolio/add or something similar the actual URL isn't really important.

So i added this to the layout file:

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

which works fine... link appears in the menu & goes where it is supposed to.

also added :

<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>

I've created and uploaded the _add template file but can't get anything but a 404 error, would be very grateful if someone could give me a shove in the right direction.

Upvotes: 0

Views: 119

Answers (1)

Marius
Marius

Reputation: 15216

First of all your layout handle for the add page should be portfolio_index_add instead of portfolio_add.
And add the following method in your IndexController.php:

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

and your path should be "portfolio/index/add"

Upvotes: 1

Related Questions