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

From aMember Pro Documentation
Jump to: navigation, search
m (Spelling, wording, grammar.)
Line 11: Line 11:
 
       // $user = $event->getUser(); // if required
 
       // $user = $event->getUser(); // if required
 
       $menu = $event->getMenu();
 
       $menu = $event->getMenu();
       // eg; add a tab
+
     
 +
       // Add a tab
 
       $menu->addPage(array(
 
       $menu->addPage(array(
 
               'id' => 'mypage',
 
               'id' => 'mypage',
Line 18: Line 19:
 
               'order' => 2,
 
               'order' => 2,
 
       ));
 
       ));
       // remove a page
+
 
 +
       // Remove a tab
 
       $page = $menu->findOneBy('id', 'add-renew');
 
       $page = $menu->findOneBy('id', 'add-renew');
 
       $menu->removePage($page);
 
       $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,
 +
      ));
 +
 
}  
 
}  
 
</source>
 
</source>

Revision as of 02:06, 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,
       ));
 
}