Difference between revisions of "How to add custom page in member area"

From aMember Pro Documentation
Jump to: navigation, search
Line 1: Line 1:
 
Add this code to [[site.php file]]:
 
Add this code to [[site.php file]]:
 
<source>
 
<source>
Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, 'myAddMenuItem');
+
Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, function (Am_Event $event) {
 
+
function myAddMenuItem(Am_Event $event)
+
{
+
 
     $menu = $event->getMenu();
 
     $menu = $event->getMenu();
 
     $menu->addPage(
 
     $menu->addPage(
Line 14: Line 11:
 
             'order' => 500
 
             'order' => 500
 
     ));
 
     ));
}
+
});
  
 
class MyPageController extends Am_Controller // a Zend_Controller_Action successor
 
class MyPageController extends Am_Controller // a Zend_Controller_Action successor

Revision as of 04:56, 5 February 2016

Add this code to site.php file:

Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, function (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');
    }
}