• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Nodes As Tabs (with tab selection)

Status
Not open for further replies.

CFodder

Well-known member
Gotta say I agree with Erich that this mod just opens up they way you can think about navigating/setting up the forums.

Have done a fresh 1.1 install on our dev site and this is the only mod I've added so far, would just like to know if it's possible to get rid of the dropdown menu? Saw the fix for 1.04 but can't seem to find what to edit for 1.1.
 

Jake Bunce

XenForo moderator
Staff member
would just like to know if it's possible to get rid of the dropdown menu?

No dropdown menu means no secondary links under the tab. Any links underneath the tab double as a dropdown menu. That means you need to do the following to have no dropdown:

1) Do not specify a links template for that node.

2) Do not enable child links for that node.

That will result in no dropdown and no secondary links for that tab.

I may be able to separate dropdowns from secondary links with some code changes. I will look into that for the next update.
 

CFodder

Well-known member
No dropdown menu means no secondary links under the tab. Any links underneath the tab double as a dropdown menu. That means you need to do the following to have no dropdown:

1) Do not specify a links template for that node.

2) Do not enable child links for that node.

That will result in no dropdown and no secondary links for that tab.

I may be able to separate dropdowns from secondary links with some code changes. I will look into that for the next update.

That would be cool if you could ta mate ... I would like the secondary links, just not the drop down ... may just be me though so whether its worth you doing it I don't know.
 

Jake Bunce

XenForo moderator
Staff member
Tried to output 3 node levels but got no solution.
I want to include in the navBar a tab with this structure:

Category
- Forum
-- SubForum

Is it possible to do with template? or anything else maybe?

I am implementing this right now. But I have a question for you and others...

The popup works as you can see in this picture:

Screen shot 2011-11-25 at 8.55.08 PM.png

But when you enter the forum the secondary links become flat:

Screen shot 2011-11-25 at 8.34.56 PM.png

How should this be handled? The row of secondary links does not accommodate a tree structure like the popup does.

My inclination is to limit the row of links to one level deep while the popup continues to show the full tree. But then you lose the ability to navigate the entire tree once you are inside of the tab.

Thoughts?
 

CyberAP

Well-known member
But when you enter the forum the secondary links become flat:

View attachment 21785

How should this be handled? The row of secondary links does not accommodate a tree structure like the popup does.

My inclination is to limit the row of links to one level deep while the popup continues to show the full tree. But then you lose the ability to navigate the entire tree once you are inside of the tab.

Thoughts?

I agree with you about one level limit in tabLinks. To solve the problem with the lost ability to navigate I suggest you to use an .account class in a tab and #AccountMenu id in Menu when selected. So the tab will be selected but the popup option will also be avaliable. Or we can use a new class and create similar CSS for it. The templates also need to be changed to suit this changes.

I am implementing this right now. But I have a question for you and others...

The popup works as you can see in this picture:

View attachment 21786

How deep it can be controlled? Can I set in a template my .menuHeader for each node at first level?
 

Brogan

XenForo moderator
Staff member
So the tab will be selected but the popup option will also be avaliable.
Personally I think that's a fairly ungainly solution and not in keeping with existing functionality.
If I saw that in use I would assume it's broken.

Secondary links will need to be limited though, as there won't be enough width to display all of them for forums with lots of nodes.
 

Jake Bunce

XenForo moderator
Staff member
Personally I think that's a fairly ungainly solution and not in keeping with existing functionality.
If I saw that in use I would assume it's broken.

Yeah that's my thinking too. I am having a hard time fitting this feature into the standard nav system in a way that is consistent and doesn't require hacks. I am still giving it some thought, but I may just end up omitting this feature from the default addon and then help you to customize it for your specific needs.
 

CyberAP

Well-known member
Yeah that's my thinking too. I am having a hard time fitting this feature into the standard nav system in a way that is consistent and doesn't require hacks. I am still giving it some thought, but I may just end up omitting this feature from the default addon and then help you to customize it for your specific needs.
If my request will ruin you general concept of no templates editing than it should not be included I think. But I would really appreciate your help in bringing this concept to life.
 

Jake Bunce

XenForo moderator
Staff member
Does this use more/less/same queries than the method below?

http://xenforo.com/community/threads/assign-pages-to-different-tabs.7006/

I created 3 addons for 3 custom tabs to function on a site of mine, and would prefer to just use one as yours does. I just wanted to know which one would tax the system less on queries. ;)

I haven't used that addon. My addon adds 1-3 queries on every forum page regardless of how many node tabs you have, plus 1 extra query if you enable the option to check child permissions. It's pretty light weight.
 

Jake Bunce

XenForo moderator
Staff member
For CyberAP...

Edit this file:

library/NodesAsTabs/Model/Options.php

Set any depth you want for the child nodes (in red):

Rich (BB code):
	// RETURNS NODE INFO OF FIRST CHILDREN NECESSARY FOR CREATING LINKS
	public function buildFirstChildList($nodeId)
	{
		$list = array();
		$childList = '';

		$nodeModel = XenForo_Model::create('XenForo_Model_Node');

		$curNode = $nodeModel->getNodeById($nodeId);
		$firstChildren = $nodeModel->getChildNodesToDepth($curNode, 1);

		foreach ($firstChildren AS $child)
		{
			$list[] = $child;
		}
		if (isset($list[0]))
		{
			$childList = serialize($list);
		}

		return $childList;
	}

Then edit and save a forum in the Admin CP to prompt a rebuild of the cache.

Then you need to edit this template:

Admin CP -> Appearance -> Templates -> nat_childlinks

I made some extra variables available to this template which allows you to handle a tree of child forums. Here is the code I used:

Code:
<xen:foreach loop="$firstChildNodes" value="$childNode">
	<xen:if is="{$childNode.level} == 1 OR !{$selected}">

	<xen:if is="!{$selected}">
		<xen:set var="$childStyle">margin-left: {xen:calc '({$childNode.level} - 1) * 20'}px;</xen:set>
	</xen:if>

	<li>
		<xen:if is="{$childNode.node_type_id} == 'Page'">
			<a href="{xen:link 'pages', $childNode}" style="{xen:raw $childStyle}">{$childNode.title}</a>
		<xen:elseif is="{$childNode.node_type_id} == 'Forum'" />
			<a href="{xen:link 'forums', $childNode}" style="{xen:raw $childStyle}">{$childNode.title}</a>
		<xen:elseif is="{$childNode.node_type_id} == 'Category'" />
			<a href="{xen:link 'categories', $childNode}" style="{xen:raw $childStyle}">{$childNode.title}</a>
		<xen:elseif is="{$childNode.node_type_id} == 'LinkForum'" />
			<a href="{xen:link 'link-forums', $childNode}" style="{xen:raw $childStyle}">{$childNode.title}</a>
		</xen:if>
	</li>

	</xen:if>
</xen:foreach>

This code differentiates between the selected tab and the non-selected tab so it displays all children in the popup and one level of children in the row. And it calculates the margin for indents based on {$childNode.level}.

Hopefully this helps you.
 

CyberAP

Well-known member
Thanks a lot! That helped to output 3 node levels. But I have a question: what template should I use to make more difficult modification to tab menu?
I want to display each 2nd node level as Heading and 3rd level as linksList.
 

Jake Bunce

XenForo moderator
Staff member
Oh OK. The heading is not normally defined in the linksTemplate. It is part of the skeleton for extra tabs in the navigation template:

Code:
				<div class="{xen:if {$extraTab.selected}, 'tabLinks', 'Menu JsOnly tabMenu'}">
					<div class="primaryContent menuHeader">
						<h3>{$extraTab.title}</h3>
						<div class="muted">{xen:phrase quick_links}</div>
					</div>
					{xen:raw $extraTab.linksTemplate}
				</div>

{xen:raw $extraTab.linksTemplate} parses to the nat_linkstemplate (unless you specify your own linksTemplate) which contains the childlinks that are built from the nat_childlinks template. Working with these 3 templates it is possible to reorganize the code so you can create headers out of childlinks.
 

CyberAP

Well-known member
I suppose the code should look like this:

linkstemplate:

PHP:
<xen:foreach loop="$childLinks" value="$childLink">
 
    <div class="primaryContent menuHeader">
        <h3>{$childLink.title}</h3>
        <div class="muted">{xen:phrase quick_links}</div>
    </div>
 
    <ul class="secondaryContent blockLinksList">
        <xen:if is="{$nodeTab.nat_markread} AND {$visitor.user_id} AND {$selected}">
        <li><a href="{xen:link 'forums/-/mark-read', $forum, 'date={$serverTime}'}" class="OverlayTrigger">{xen:phrase mark_forums_read}</a></li>
        </xen:if>
   
        {xen:raw $childLinks}
    </ul>
 
</xen:foreach>

And childLinks:

PHP:
<xen:foreach loop="$firstChildNodes" value="$childNode">
    <xen:if is="{$childNode.level} == 1 OR !{$selected}">
 
    <xen:if is="!{$selected}">
        <xen:set var="$childStyle">margin-left: {xen:calc '({$childNode.level} - 1) * 20'}px;</xen:set>
    </xen:if>
 
    <li>
        <xen:if is="{$childNode.node_type_id} == 'Page'">
            <a href="{xen:link 'pages', $childNode}" style="{xen:raw $childStyle}">{$childNode.title}</a>
        <xen:elseif is="{$childNode.node_type_id} == 'Forum'" />
            <a href="{xen:link 'forums', $childNode}" style="{xen:raw $childStyle}">{$childNode.title}</a>
        <xen:elseif is="{$childNode.node_type_id} == 'Category'" />
            <a href="{xen:link 'categories', $childNode}" style="{xen:raw $childStyle}">{$childNode.title}</a>
        <xen:elseif is="{$childNode.node_type_id} == 'LinkForum'" />
            <a href="{xen:link 'link-forums', $childNode}" style="{xen:raw $childStyle}">{$childNode.title}</a>
        </xen:if>
    </li>
 
    </xen:if>
</xen:foreach>

But in Linkstemplate I don't know what array I should you to get it working.
 

Anthony Parsons

Well-known member
I think the dropdown and second level links can get very ugly depending on how many forums / pages are created as childs to any node.

My thinking would be, that only direct children to a node should show as secondary links. When you click the next level, then those children show, etc etc.

Even then... if you have 30 children to a node, you couldn't show all 30 links in a dropdown or secondary level, as it would distort secondary level and a dropdown would be quite unreadable with that many links.

I think you're in-between a rock and a hard place with this one Jake! Tough choices on how to best handle that one.
 

Dismal Shadow

Active member
Personally I think that's a fairly ungainly solution and not in keeping with existing functionality.
If I saw that in use I would assume it's broken.

Secondary links will need to be limited though, as there won't be enough width to display all of them for forums with lots of nodes.
Brogan, if I can ask, is this the mod you use on your site?
 
Status
Not open for further replies.
Top