Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you want to add a custom menu on user profile page same as the core apps. Please follow below instructions:

Note: We will use the code of To Do List app as an example for this tutorial.

...

Code Block
languagephp
themeRDark
borderStylesolid
linenumberstrue
collapsetrue

/** 
 * Return string to generate url
 * @return string 
 */ 
public function getProfileLink() 
{
    return 'profile.todo'; //the link when users click on the custom menu
} 

/** 
 * Set menu in profile 
 * @param array $aUser 
 * @return array|bool 
 */ 
public function getProfileMenu($aUser) 
{ 
    $iTasksCnt = Phpfox::getService('todo')->get(['user_id' => $aUser['user_id']], true); 

    if (!Phpfox::getParam('profile.show_empty_tabs') && !$iTasksCnt) { 
        return false; 
    } 

    $aMenus[] = [ 
        'phrase'   => _p('to_do_list'),  //phrase the custom menu
        'url'      => 'profile.todo',  //the link when users click on the custom menu
        'total'    => $iTasksCnt,   //counter shown on the menu
    ]; 

    return $aMenus; 
}