Mikkel-T Posted April 8, 2018 Share Posted April 8, 2018 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..? Link to comment Share on other sites More sharing options...
HeadStand Posted April 9, 2018 Share Posted April 9, 2018 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, '*' ) ); } } Link to comment Share on other sites More sharing options...
bfarber Posted April 9, 2018 Share Posted April 9, 2018 Commerce does this, you can look at it as an example of how to accomplish what you are after. Link to comment Share on other sites More sharing options...
Mikkel-T Posted April 9, 2018 Author Share Posted April 9, 2018 @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. Link to comment Share on other sites More sharing options...
HeadStand Posted April 10, 2018 Share Posted April 10, 2018 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. Link to comment Share on other sites More sharing options...
Midnight Modding Posted April 10, 2018 Share Posted April 10, 2018 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.