What it is
MobileNavigation extensions are used to add new tabs to the mobile app navigation menu, tying in directly with the menu manager in the AdminCP.
How to use
Many of the same methods are implemented as the core/FrontNavigation extension so if you are familiar with this extension you already have a head start.
Implemented methods in the mobile navigation extension are as follows;
/**
* Can the currently logged in user access the content this item links to?
*
* @return bool
*/
public function canAccessContent()
The canAccessContent() method allows you to dynamically check if the current viewing member an access the page or not. Often this will come down to checking if the member can access the module or not, however you can perform whatever checks you want, returning TRUE if the member can access the tab and FALSE if not.
/**
* Get Title
*
* @return string
*/
public function title()
The title() method returns the tab title to display within the app.
/**
* Get Link
*
* @return \IPS\Http\Url
*/
public function link()
The link() method, as you might expect, returns the link that the tab should point to. A full \IPS\Http\Url object should be returned.
/**
* Permissions can be inherited?
*
* @return bool
*/
public static function permissionsCanInherit()
By default permissions can be inherited by menu items (e.g. if you cannot access any menu items, do not show the tab), however you can disable this if you wish by overriding this method and returning FALSE.
/**
* Allow multiple instances?
*
* @return string
*/
public static function allowMultiple()
By default, only one instance of a menu item is available to set up (so you cannot create two 'Gallery' tabs by choosing Gallery in the menu manager), however if your menu class would benefit from supporting multiple instances this method can be overridden and return TRUE. This is used for the base generic Menu mobile navigation extension, for instance, as you may want to create multiple menus.
/**
* Get configuration fields
*
* @param array $configuration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function configuration( $existingConfiguration, $id = NULL )
If your menu requires special configuration, you can define a static configuration() method to return an array of form helper elements to display in order to configure the menu.
/**
* Parse configuration fields
*
* @param array $configuration The values received from the form
* @return array
*/
public static function parseConfiguration( $configuration, $id )
If your menu requires special configuration, you can define a static parseConfiguration() method to process the form helper elements returned with the configuration() method described above.
/**
* Can this item be used at all?
* For example, if this will link to a particular feature which has been diabled, it should
* not be available, even if the user has permission
*
* @return bool
*/
public static function isEnabled()
As the docblock states, you can return FALSE from the isEnabled() method if you need to completely disable the menu item regardless of user permissions.
MobileNavigation extensions extend \IPS\core\MobileNavigation\MobileNavigationAbstract so it is worth taking a look at this class to understand the methods being extended and how they interact if there is any confusion.
Report Document