How to add custom page in member area

From aMember Pro Documentation
Revision as of 01:24, 2 October 2012 by Caesar (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Create /amember/application/configs/site.php with this code:

Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, 'myAddMenuItem');
 
function myAddMenuItem(Am_Event $event)
{
    $menu = $event->getMenu();
    $menu->addPage(
        array(
            'id' => 'my-page-id',
            'controller' => 'my-page',
            'module' => 'default',
            'label' => "My Page",
            'order' => 500
    ));
}
 
class MyPageController extends Am_Controller // a Zend_Controller_Action successor
{
    function indexAction()
    {
        $user = $this->getDi()->user; //currently authenticated customer or throws exception if no auth
 
        $this->view->title = "My Page";
        $this->view->content = "Page content";
        $this->view->display('layout.phtml');
    }
}