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

Three Routes In One Selected NavTab

Discussion in 'XenForo Development Discussions' started by Marcus, Nov 23, 2012.

  1. Marcus

    Marcus Well-Known Member

    Example: My forum has a navtab "horror". There is a route horror and it works with that. But there are also other routes horrorbooks and horrormovies.
    How could I combine all three routes in 'selected' => ($selectedTabId == 'horror')?
    PHP:
    <?php 
    class MyProduct_Listener
    {
        public static function 
    navTabs(array &$extraTabs$selectedTabId)
        {    
            
    $extraTabs['product'] = array(
                    
    'title' => 'horror',
                    
    'href' => XenForo_Link::buildPublicLink('full:horror'),
                    
    'selected' =>  ($selectedTabId == 'horror'),
                    
    'position' => 'middle',
                    
    'linksTemplate' => 'horror_navtab',
            );
        }
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    When you're creating your templates, you will use something like this for your Horror Books page, for example:

    Code:
    <xen:navigation>
    <xen:breadcrumb href="{xen:link full:horror}">Horror</xen:breadcrumb>
    <xen:breadcrumb href="{xen:link full:horrorbooks}">Horror Books</xen:breadcrumb>
    </xen:navigation>
    With that code, the template will know to ensure the selected tab is horror.
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  4. Marcus

    Marcus Well-Known Member

    Ok it's easy. Just have "horror" as a parameter at the end of the getRouteMatch function for each match.

    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
    $action = $router->resolveActionWithIntegerParam($routePath, $request, 'invoice_id');

    return $router->getRouteMatch('Horror_ControllerPublic_HorrorBooks', $action, horror);
    }

    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
    $action = $router->resolveActionWithIntegerParam($routePath, $request, 'invoice_id');

    return $router->getRouteMatch('Horror_ControllerPublic_HorrorMovies', $action, horror);
    }
     
  5. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Just to make it clear... the $majorSection (the'end' one) needs to be the same as the id of the navTab... XenForo will do the rest ;)
     
    Jake Bunce and Marcus like this.

Share This Page