Posted April 8, 20187 yr I tried to create a front navigation extension, but I'm having troubles creating "sub menus" for it. Example: I have a feeling I see I should be using the children method, but it returns an array, I'm not too sure of what..?
April 9, 20187 yr The children method will generate a dropdown menu, not sub-menus. Ideally, you should be creating a FrontNavigation extension for each of the menu items you want, and then use the defaultFrontNavigation method in your Application.php file to put the menus where you want on installation. (Note: you will need to manually build your menu in the Menu Manager if you are in development mode OR if your app is already installed on the server.) For your own information... sample of a working FrontNavigation extension with children. /** * Front Navigation Extension: Moderate */ class _Moderate extends \IPS\core\FrontNavigation\FrontNavigationAbstract { /** * Get Type Title which will display in the AdminCP Menu Manager * * @return string */ public static function typeTitle() { return \IPS\Member::loggedIn()->language()->addToStack( 'frontnavigation_proplibrary_moderate' ); } /** * Can access? * * @return bool */ public function canView() { // only admins can see this return \IPS\Member::loggedIn()->isAdmin(); } /** * Get Title * * @return string */ public function title() { if( isset( $this->configuration['action'] ) && $this->configuration['action'] ) { return \IPS\Member::loggedIn()->language()->addToStack( 'module__proplibrary_moderate_' . $this->configuration['action'] ); } return \IPS\Member::loggedIn()->language()->addToStack( 'frontnavigation_proplibrary_moderate' ); } /** * Get Link * * @return \IPS\Http\Url */ public function link() { $key = ( isset( $this->configuration['action'] ) && $this->configuration['action'] ) ? $this->configuration['action'] : 'authors'; return \IPS\Http\Url::internal( "app=proplibrary&module=moderate&controller={$key}" ); } /** * Is Active? * * @return bool */ public function active() { return \IPS\Dispatcher::i()->application->directory === 'proplibrary' && \IPS\Dispatcher::i()->module && \IPS\Dispatcher::i()->module->key == 'moderate'; } /** * Children * * @param bool $noStore If true, will skip datastore and get from DB (used for ACP preview) * @return array */ public function children( $noStore=FALSE ) { if( isset( $this->configuration['action'] ) && $this->configuration['action'] ) { return array(); } return array( new \IPS\proplibrary\extensions\core\FrontNavigation\Moderate( array( 'action' => 'authors', ), 0, '*' ), new \IPS\proplibrary\extensions\core\FrontNavigation\Moderate( array( 'action' => 'roots' ), 0, '*' ), new \IPS\proplibrary\extensions\core\FrontNavigation\Moderate( array( 'action' => 'links' ),0, '*' ), new \IPS\proplibrary\extensions\core\FrontNavigation\Moderate( array( 'action' => 'drafts' ), 0, '*' ) ); } }
April 9, 20187 yr Commerce does this, you can look at it as an example of how to accomplish what you are after.
April 9, 20187 yr Author @HeadStand I guess what I want is a root tab, with 2 sub menus. I'm not sure I understand the part of the menu builder. Currently it can only link to a single item (my extension), and I cannot add sub-menus to that one, using the manager.
April 10, 20187 yr 4 hours ago, Mikkel-T said: @HeadStand I guess what I want is a root tab, with 2 sub menus. I'm not sure I understand the part of the menu builder. Currently it can only link to a single item (my extension), and I cannot add sub-menus to that one, using the manager. There's no reason you shouldn't be able to drag something under your item.
April 10, 20187 yr yeah, I think I saw that before and originally didn't realize you can drop them under other menus. This may come in handy for me, eventually.
Archived
This topic is now archived and is closed to further replies.