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

XF 1.1 How do I set Parent node to 'Media tab', for created pages which default to Forum tab?

Discussion in 'Troubleshooting and Problems' started by CritiKiL, Apr 16, 2012.

  1. CritiKiL

    CritiKiL Active Member

    Ok. I created sub-link 'pages' and have them as sub-links on the Media tab. But when I click on those sub-links it shows the correct page, but the parent node goes to the Forum tab always. I would like (when they are clicked) for them to stay on the tab to which I placed the links, so how can I "make my Media tab" (the tab where I have the sub-links located) as the Parent node, since the Media tab is not included as a parent node choice? The site location where I have this problem is Below and the sub-link created pages are 'Clanradio', 'Clancast', 'ClanKill TV' and 'UFreqTV':

    http://sck-mobile.com/community/index.php?media/
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Those are page nodes which are assigned to the default Forums tab. You can change this by modifying this file:

    XenForo/Route/Prefix/Pages.php

    Change the red part to media which is the major section for the Media tab:

    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)
    	{
    		$request->setParam('node_name', basename($routePath));
    
    		return $router->getRouteMatch('XenForo_ControllerPublic_Page', 'index', 'forums');
    	}
    
    However, this will affect all page nodes. If this is a problem for you then you can use this code to change the major section for specific node names:

    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)
    	{
    		$request->setParam('node_name', basename($routePath));
    
    		return $router->getRouteMatch('XenForo_ControllerPublic_Page', 'index', (in_array($request->getParam('node_name'), array('clancast', 'clankill_tv', 'ufreqtv')) ? 'media' : 'forums'));
    	}
    
     
    thedude, DRE and CritiKiL like this.
  3. CritiKiL

    CritiKiL Active Member

    Works perfectly, (the second code)! Thank Jake 'again and again' ;-)
     
  4. CritiKiL

    CritiKiL Active Member

    Ok, Now I need to add this situation as well:

    'warroom-1' and 'pws-1' pages, re-routed to the 'xboxlive-leaderboard' (Warroom) tab...
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Let's change it up a bit for more conditions:

    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)
    	{
    		$request->setParam('node_name', basename($routePath));
    
    		if (in_array($request->getParam('node_name'), array('clancast', 'clankill_tv', 'ufreqtv')))
    		{
    			$section = 'media';
    		}
    		else if (in_array($request->getParam('node_name'), array('warroom-1', 'pws-1')))
    		{
    			$section = 'xboxlive-leaderboard';
    		}
    		else
    		{
    			$section = 'forums';
    		}
    
    		return $router->getRouteMatch('XenForo_ControllerPublic_Page', 'index', $section);
    	}
    
     
    DRE likes this.
  6. CritiKiL

    CritiKiL Active Member

    Got it! (y)
     
  7. CritiKiL

    CritiKiL Active Member

    UPDATE:

    Ok, I tried to do this with 'one more' situation. I've added an 'image gallery' and I wish for that to be accessible from the MEDIA tab as well. So I duplicated the 3 sub-links: (Gallery, Create, View) into the MEDIA tab. Now I wish to:

    1) Remove the USER ALBUMS tab completely.
    2) Make the 3 sub-links stay on the new location tab (MEDIA), when they are clicked.

    Can you help? I tried using the code to include this but it did not work...
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    1) Edit this template:

    Admin CP -> Appearance -> Templates -> EXTRA.css

    Add this code:

    Code:
    .navTabs .navTab.useralbums
    {
    	display: none;
    }
    
    2) Edit this file:

    library/XfRu/UserAlbums/Route/Prefix/UserAlbums.php

    Change the red piece to 'media':

    Code:
    	private function getMajorSection($key = '')
    	{
    		$section = 'useralbums';
    	    $section .= (!empty($key)) ? '/'.$key : '' ;
    	    return $section;
    	}
    
     
    CritiKiL likes this.
  9. CritiKiL

    CritiKiL Active Member

    Wow, Thanks Jake ;)
     
  10. CritiKiL

    CritiKiL Active Member

    Oops. I just noticed that when we fixed Album part, now the previous things we did initially don't anchor to the MEDIA tab anymore. Instead they just show all empty sub-links when clicked (ex: 'clancast', 'clankilltv' and 'ufreqtv' off the media tab) and ('matches played' and 'player war stats' off the Warroom tab). I tried putting the original Album file back but now none of the previous re-routes work, so I put the Album edits back to how you told me to do them...
     
  11. CritiKiL

    CritiKiL Active Member

    My apologies, I have to stop pulling all day coding! It was something I had tried to do the Album issue by modifying the code you gave me above for PAGES, and then I forgot my edited version was already on the server so that by the time I put in your second code for the Album...it slipped my mind that my version was why things did not work. ;-)
     
  12. CritiKiL

    CritiKiL Active Member

    Jake. I want to do just one more (I know I shouldn't say that: "One More?" lol) where I have combined the Members and XenStaff tabs. The Members is a part of the XenStaff, and I tried to include that array situation to no avail. Looking to have 'members', 'online' and 'recent-activity' to stay on the 'XenStaff' (USERS) tab...

    BTW: I saw your update on the Nodes as Tabs, but that doesn't apply in this last case, right?
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    library/XenForo/Route/Prefix/Members.php

    Replace the red piece with 'xfx_staff':

    Code:
    	public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    	{
    		$action = $router->resolveActionWithIntegerParam($routePath, $request, 'user_id');
    		return $router->getRouteMatch('XenForo_ControllerPublic_Member', $action, 'members');
    	}
    
    The update shouldn't affect these changes.
     
    Coop1979 and CritiKiL like this.
  14. CritiKiL

    CritiKiL Active Member

    Ok the 'members' part works but not the 'online' (Current Members Online), and 'recent-activity' (Recent Activity) sub-links...

    OOOPS! I followed your lead and modded the 'Online.php & RecentActivity.php' files, accordingly! Thanks Jake!!!
     
  15. CritiKiL

    CritiKiL Active Member

    Jake. I 'now' have a 'forum link' (not a 'thread' or 'page' this time), of which points to this: http://sck-mobile.com/community/ezstats2_bf3.php. However I have the url link located here, under Warroom / BF3 Leaderboard / [SCK] BF3 Plattoon Stats. How can I keep the 'forum link' to stay where it is located?
     
  16. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    CritiKiL likes this.
  17. CritiKiL

    CritiKiL Active Member

    When you say 'route handler' I don't know exactly how to find out if there is one or if one can be made?
     
  18. CritiKiL

    CritiKiL Active Member

    Ok, I found another link to that script, as it's a part of XF because it is a 'forum-link' not a page: http://sck-mobile.com/community/index.php?link-forums/bf3-leaderboard.105/.

    So I tried taking the Link-forums.php file and editing it to look like this (see below), but that doesn't work. I changed this:
    Code:
    return $router->getRouteMatch('XenForo_ControllerPublic_LinkForum', $action, 'forums');
    To this:
    Code:
    return $router->getRouteMatch('XenForo_ControllerPublic_LinkForum', $action,  (in_array($request->getParam('node_name'), array('ezstats2_bf3.php')) ? 'xboxlive-leaderboard' : 'forums'));
    and to this:
    Code:
    return $router->getRouteMatch('XenForo_ControllerPublic_LinkForum', $action,  (in_array($request->getParam('node_name'), array('bf3-leaderboard.105')) ? 'xboxlive-leaderboard' : 'forums'));
    ...but those did nothing.
     
  19. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Link forums don't feature tab-selection. They are merely redirects.

    If you post the code from that script then I can look it over.
     
  20. CritiKiL

    CritiKiL Active Member

    LinkForums.php (original script):

    Code:
    <?php
     
    /**
    * Route prefix handler for link forums in the public system.
    *
    * @package XenForo_Nodes
    */
    class XenForo_Route_Prefix_LinkForums implements XenForo_Route_Interface
    {
        /**
        * 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)
        {
            $action = $router->resolveActionWithIntegerParam($routePath, $request, 'node_id');
            return $router->getRouteMatch('XenForo_ControllerPublic_LinkForum', $action, 'forums');
        }
     
        /**
        * Method to build a link to the specified page/action with the provided
        * data and params.
        *
        * @see XenForo_Route_BuilderInterface
        */
        public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
        {
            // for situations such as an array with thread and node info
            if (isset($data['node_title']))
            {
                $data['title'] = $data['node_title'];
            }
     
            return XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, 'node_id', 'title');
        }
    }
     

Share This Page