1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Navigation link de-selects Forums tab

Discussion in 'XenForo Development Discussions' started by AndyB, Nov 6, 2014.

  1. AndyB

    AndyB Well-Known Member

    Hello,

    I have an add-on I'm developing called Advanced Search. There is a link to the add-on located under the Forums tab. You can see it here:

    http://www.southbayriders.com/forums/

    When I click the Advanced Search link, the Forums tab is no longer highlighted. How can I make the Forums tab continue to be selected after I click the Advanced Search link?

    Thank you.
     
  2. Valhalla

    Valhalla Well-Known Member

    For example:

    ../Route/Prefix/AdvancedSearch.php

    Code:
    /**
    * Match a specific route for an already matched prefix.
    *
    * @see XenForo_Route_Interface::match()
    */
    
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        return $router->getRouteMatch('AdvancedSearch_ControllerPublic_AdvancedSearch', $routePath, 'forums');
    }
    
     
    AndyB likes this.
  3. AndyB

    AndyB Well-Known Member

    Hi Valhalla,

    Thank you for taking the time to look into this. The code example you provided, where would I use this?

    This is what I currently have for my PHP file Andy/AdvancedSearch/ControllerPublic/AdvancedSearch.php

    PHP:
    <?php

    class Andy_AdvancedSearch_ControllerPublic_AdvancedSearch extends XenForo_ControllerPublic_Abstract
    {
        public function 
    actionIndex()
        {
            
    // get user group permissions
            
    if (!XenForo_Visitor::getInstance()->hasPermission('advancedSearchGroupID''advancedSearchID'))
            {
                throw 
    $this->getNoPermissionResponseException();
            }

            
    // send to template
            
    return $this->responseView('Andy_AdvancedSearch_ViewPublic_AdvancedSearch''andy_advancedsearch');
        }
     
  4. AndyB

    AndyB Well-Known Member

    If I try this:

    PHP:
            // send to template
            
    return $this->responseView('Andy_AdvancedSearch_ViewPublic_AdvancedSearch''andy_advancedsearch''forums');
    I get this error:

    pic001.jpg
     
  5. Valhalla

    Valhalla Well-Known Member

    Have you created a Route Prefix for your new page? (In Development -> Route Prefixes)

    Screen Shot 2014-11-06 at 20.03.16.png

    Once you have created the new Route Class as above, you can refer to your ControllerPublic file (the one you posted above):

    PHP:
    <?php

    class Andy_AdvancedSearch_Route_Prefix_AdvancedSearch implements XenForo_Route_Interface
    {
        
    /**
        * Match a specific route for an already matched prefix.
        *
        * @see XenForo_Route_Interface::match()
        */
        
    public function match($routePathZend_Controller_Request_Http $requestXenForo_Router $router)
        {
            return 
    $router->getRouteMatch('Andy_AdvancedSearch_ControllerPublic_AdvancedSearch'$routePath'forums');
        }
    }

    ?>
    Screen Shot 2014-11-06 at 20.13.04.png
     
    Last edited: Nov 6, 2014
    AndyB likes this.
  6. AndyB

    AndyB Well-Known Member

    Got it!

    Thank you so much, Valhalla.

    Adding 'forums' to the Andy/AdvancedSearch/Route/Prefix/AdvancedSearch was all I was missing. I knew how to do this, but forgot that is where I needed to add 'forums'.
     
  7. Valhalla

    Valhalla Well-Known Member

    I'm glad you got it working. :)
     

Share This Page