Jump to content

Recommended Posts

Posted

Hi,

I setup a furl in the .json file in the data of my custom application 

{
  "topLevel": "servers",
  "pages": {
    "servers": {
      "friendly": "servers",
      "real": "app=serversapp&module=servers&controller=servers"
    }
  }
}

This works on my dev site to show dev.com/servers 

But when I added an extension to add this to the front navigation when I click on the Servers menu item it brings me to dev.com/servers/servers

The code for the front navigation is:

<?php
/**
 * @brief     Front Navigation Extension: servers
 * @author    <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
 * @copyright  (c) Invision Power Services, Inc.
 * @license       https://www.invisioncommunity.com/legal/standards/
 * @package       Invision Community
 * @subpackage JR Servers
 * @since     20 May 2022
 */

namespace IPS\serversapp\extensions\core\FrontNavigation;

/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
   header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
   exit;
}

/**
 * Front Navigation Extension: servers
 */
class _servers 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_serversapp');
   }
   
   /**
    * 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()
   {
      return TRUE;
   }
   
   /**
    * Can the currently logged in user access the content this item links to?
    *
    * @return bool
    */
   public function canAccessContent()
   {
       return \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'servers', 'servers' ) );
   }
   
   /**
    * Get Title
    *
    * @return string
    */
   public function title()
   {
      return \IPS\Member::loggedIn()->language()->addToStack('frontnavigation_serversapp');
   }
   
   /**
    * Get Link
    *
    * @return \IPS\Http\Url
    */
   public function link()
   {
        return \IPS\Http\Url::internal( "app=serversapp&module=servers&controller=servers", 'front', 'servers' );
   }
   
   /**
    * Is Active?
    *
    * @return bool
    */
   public function active()
   {
      return \IPS\Dispatcher::i()->application->directory === 'serversapp';
   }

   /**
    * Children
    *
    * @param  bool   $noStore   If true, will skip datastore and get from DB (used for ACP preview)
    * @return array
    */
   public function children( $noStore=FALSE )
   {
      return NULL;
   }
}

 

Does anyone have any idea why this could be happening, a pointer in the right direction would really help.

Posted

Fixed it,

"topLevel": "servers",
"pages": {
  "servers": {
    "friendly": "",
    "real": "app=serversapp&module=servers&do=list"
  },

 

I found if you emptied the friendly it will use the top level for the app.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...