Difference between revisions of "How to customize user tabs in member's area"

From aMember Pro Documentation
Jump to: navigation, search
Line 25: Line 25:
 
   
 
   
 
       // Add sub item to exiting tab
 
       // Add sub item to exiting tab
       $page = $menu->findOneBy('id', 'aff'); //get affiliate page  
+
       $page = $menu->findOneBy('id', 'aff'); // get affiliate page  
 
       $page->addPage(array(
 
       $page->addPage(array(
 
               'id' => 'my-subitem',
 
               'id' => 'my-subitem',

Revision as of 02:07, 19 November 2012

Let's say you want to add a tab to the member's area and remove the Add/Renew tab.


Add this code to /amember/application/configs/site.php:

<?php
Am_Di::getInstance()->hook->add('userMenu', 'siteUserMenu');
function siteUserMenu(Am_Event $event)
{
      // $user = $event->getUser(); // if required
      $menu = $event->getMenu();
 
      // Add a tab
      $menu->addPage(array(
              'id' => 'mypage',
              'label' => ___('Do The Thing'),
              'uri' => '/the.thing',
              'order' => 2,
       ));
 
       // Remove a tab
       $page = $menu->findOneBy('id', 'add-renew');
       $menu->removePage($page);
 
       // Add sub item to exiting tab
       $page = $menu->findOneBy('id', 'aff'); // get affiliate page 
       $page->addPage(array(
              'id' => 'my-subitem',
              'label' => ___('Subitem'),
              'uri' => '/sub.item',
              'target' => '_blank', // you can set target attribute if necessary
              'order' => 10,
       ));
 
}