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

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/
 
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:

Rich (BB 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:

Rich (BB 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'));
	}
 
Let's change it up a bit for more conditions:

Rich (BB 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);
	}
 
  • Like
Reactions: DRE
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...
 
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':

Rich (BB code):
	private function getMajorSection($key = '')
	{
		$section = 'useralbums';
	    $section .= (!empty($key)) ? '/'.$key : '' ;
	    return $section;
	}
 
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...
 
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. ;-)
 
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?
 
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...

library/XenForo/Route/Prefix/Members.php

Replace the red piece with 'xfx_staff':

Rich (BB 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');
	}

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

The update shouldn't affect these changes.
 
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!!!
 
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.
 
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');
    }
}
 
Top Bottom