vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   vB4.2 Navigation Manager - how to discussion (https://vborg.vbsupport.ru/showthread.php?t=283146)

AusPhotography 05-18-2012 10:00 PM

vB4.2 Navigation Manager - how to discussion
 
I have vB 4.2.0 BETA 1 running in my test system.

Products that use templates/hooks to integrate with the navbar will need the following changes to work with the Navigation Manager.

Please post code snips and hints in this thread, we are all on a learning curve.

1. Remove old style navigation hooks/templates etc.

2. Create a new <navigation> section in the product XML file
(You can create the navigation in the navigation manager, linked to a product then export the product file as a skeleton)

3. Set any conditionals in a hook or in your main code
Eg. $show['apmgtug'] = true; is set for one of the menu items in my example
My example relies on $show['member'] = true; as well.
Leave the <show> tag empty for 'public' tabs/links

4. If you have multiple scripts, leave <scripts> blank and set $root at the new hooks set_navigation_tab_fallaback or set_navigation_tab_vbview

Code:

if (<some condition>) $root= '<name of tab>';
I hope that helps you get a quick leg up for this change.

I would probably have a new vB4.2 code base because of the differences, you could have the same code base with some sort of version check.

In the end the new navigation integration is better and easier.

Here are sample <navigation> from one of my own plugins...

Code:

        <navigation>
                <tab name="aptab_competition" date="1337135420" username="APcompetition" version="3.0.0">
                        <active>1</active>
                        <show>member</show>
                        <scripts>apcompetition</scripts>
                        <displayorder>30</displayorder>
                        <url><![CDATA[apcompetition.php{session.sessionurl_q}]]></url>
                </tab>
                <link name="aplink_enter" date="1337135420" username="APcompetition" version="3.0.0">
                        <active>1</active>
                        <show>member</show>
                        <parent>aptab_competition</parent>
                        <displayorder>20</displayorder>
                        <url><![CDATA[apcompetition.php{session.sessionurl_q}]]></url>
                </link>
                <link name="aplink_search" date="1337135420" username="APcompetition" version="3.0.0">
                        <active>1</active>
                        <show>member</show>
                        <parent>aptab_competition</parent>
                        <displayorder>40</displayorder>
                        <url><![CDATA[apcompetition.php?{vb:raw session.sessionurl}do=search&apmycomps=1]]></url>
                </link>
                <link name="aplink_performance" date="1337135420" username="APcompetition" version="3.0.0">
                        <active>1</active>
                        <show>member</show>
                        <parent>aptab_competition</parent>
                        <displayorder>60</displayorder>
                        <url><![CDATA[apcompetition.php?{vb:raw session.sessionurl}do=performance]]></url>
                </link>
                <link name="aplink_fame" date="1337135420" username="APcompetition" version="3.0.0">
                        <active>1</active>
                        <show>apmgtug</show>
                        <parent>aptab_competition</parent>
                        <displayorder>80</displayorder>
                        <url><![CDATA[apcompetition.php?{vb:raw session.sessionurl}do=finalvotereport]]></url>
                </link>
        </navigation>

Sample phrases the give the text of the navigation items.
Code:

                <phrasetype name="GLOBAL" fieldname="global">
                        <phrase name="vb_navigation_tab_aptab_competition_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[Competitions]]></phrase>
                        <phrase name="vb_navigation_link_aplink_enter_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[Enter a Competition]]></phrase>
                        <phrase name="vb_navigation_link_aplink_search_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[Search Competitions]]></phrase>
                        <phrase name="vb_navigation_link_aplink_performance_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[My Performance]]></phrase>
                        <phrase name="vb_navigation_link_aplink_fame_text" date="1336964077" username="APcompetition" version="3.0.0"><![CDATA[Hall of Fame]]></phrase>
                </phrasetype>

--------------- Added [DATE]1337391078[/DATE] at [TIME]1337391078[/TIME] ---------------

Pull down menu's can also be coded.
Have a look at the vB source for examples.
Specifically "./install/vbulletin-navigation.xml"

nhawk 05-19-2012 10:01 AM

FYI, the navtab_end template hook in 4.2.0 still works the same as it did in 4.1.12.

It's the navbar that gives headaches.

You can add to the navbar with a DB routine too.

EDIT: But this does totally screw up dynamically built navbar links. On first glance it looks like a phrase needs to be created for each navbar link. If that's the case, the maintenance DB routines for a dynamically created link will be interesting.

Paul M 05-19-2012 12:34 PM

FYI, the 'show' check can use multiple variables, so if you want a link to only appear if $show['cond1'] and $show['cond2'] are set, you add them both, separated by a dot

<show>cond1.cond2</show>

Custom $show variables can be created pretty much in any hook, as the navigation is almost the last thing built, but two common ones added for the purpose are load_show_variables & load_forum_show_variables.

Andreas 05-19-2012 03:34 PM

Quote:

But this does totally screw up dynamically built navbar links
IMHO, there should be no dynamically created links as this defeats the purpose of the navigation manager, which is to allow the administrator full control over the menu structure.

May I ask why you would need dynamically created links?

nhawk 05-19-2012 04:04 PM

Quote:

Originally Posted by Andreas (Post 2330741)
IMHO, there should be no dynamically created links as this defeats the purpose of the navigation manager, which is to allow the administrator full control over the menu structure.

May I ask why you would need dynamically created links?

Posted on vB.com..

'user' in this case means the administrator.

ie: A mod uses a portion of the information entered by the user for the navbar link, say the 'title' portion of the user entry. In order to create the navbar link in the community menu, that 'title' must be also be saved in the phrase table of vB. And then the additional navbar link must be created in the navigation table. Along with that a $show variable must be created in a plugin if the member has permission to view that link.

Now because different 'titles' can have different permissions, there has to be a different $show for each menu item.

That seems like a lot to go through for something that use to take a one line piece of code to throw the menu selection in the community menu in earlier versions.

Andreas 05-19-2012 04:32 PM

Quote:

Originally Posted by nhawk (Post 2330748)
A mod uses a portion of the information entered by the user for the navbar link, say the 'title' portion of the user entry. In order to create the navbar link in the community menu, that 'title' must be also be saved in the phrase table of vB.

Can you give a concreate example of an Add-on so it is easier to understand what exactly you are talking abount?
As far as I understand you intentions by now is that the Add-on allows the administrator to set the title for a link in the Community Menu on the Forum tab?
This can easily be achived by just using the Navigation Manager to rename the link.


Quote:

And then the additional navbar link must be created in the navigation table.
If it is a "static" link - yes, it should be added to the navigation table upon Add-on installation.
(Which will happen automatically if you have already added that link on your developement system, assigned in to the Add-on and exported the XML).


Quote:

Along with that a $show variable must be created in a plugin if the member has permission to view that link.

Now because different 'titles' can have different permissions, there has to be a different $show for each menu item.
Yes, you have to check the permissions and set a flag wether to show the link or not.
But again this is not different from how it worked in vB 4.1


Quote:

That seems like a lot to go through for something that use to take a one line piece of code to throw the menu selection in the community menu in earlier versions.
Not really, in fact it does require less work in my mind:

In vB 4.1 you had to
  • Add a template for the link
  • Add the phrase for the link
  • Create a setting to let the user select where the link should appear (eg. template hook)
  • Write code to check the setting, the user permissions and to render the template for the selected template hook
... and still the administrator might have wanted to have the link appear on a completely different location

In vB 4.2
  • Add the link in Navigation Manager
  • Write a Plug-in to check permissions and set the $show-Flag

nhawk 05-19-2012 04:39 PM

Quote:

Originally Posted by Andreas (Post 2330753)
Can you give a concreate example of an Add-on so it is easier to understand what exactly you are talking abount?

Sure.. it's my Advanced Application Forms..

Here's a snippet of the code to add an application type to the community menu...
Code:

while($application = $vbulletin->db->fetch_array($applications))
{
        if ($vbulletin->options['advapp_inmenu'] && $vbulletin->userinfo['posts'] >= intval($application['postcount']) && is_member_of($vbulletin->userinfo, explode(',', $application['usergroup'])) && $application['community'] && $application['active'])
        {
                $template_hook['navbar_community_menu_end'] .= '<li><a href="application-forms.php?appid=' . $application['appid'] . '" title="' . $application['description'] . '">' . $application['type'] . '</a></li>';
        }
}

Don't get me wrong. I can create the menu in the database when the application is created. It just seems like more work to me.

This reminds me of the addition of the <vb:each> in templates...
Nobody is going to tell me that reading a database, parse the data to build an array, sending that array to the template and parsing it a second time is faster than bulding/formating the array and sending it in all one lump piece of data to the template. It's just not possible. Two parses take double the time. But that's a different topic. ;)

Andreas 05-19-2012 05:17 PM

Quote:

Originally Posted by nhawk (Post 2330756)
Here's a snippet of the code to add an application type to the community menu...
Code:

while($application = $vbulletin->db->fetch_array($applications))
{
        if ($vbulletin->options['advapp_inmenu'] && $vbulletin->userinfo['posts'] >= intval($application['postcount']) && is_member_of($vbulletin->userinfo, explode(',', $application['usergroup'])) && $application['community'] && $application['active'])
        {
                $template_hook['navbar_community_menu_end'] .= '<li><a href="application-forms.php?appid=' . $application['appid'] . '" title="' . $application['description'] . '">' . $application['type'] . '</a></li>';
        }
}


Thanks, that's what I expected :)

The idea behind Navigation Manager is to give the Administrator full control over the menu structure - if you are creating links dynamically at runtime (which is still possible) you are IMHO somewhat defeating that goal.

Quote:

This reminds me of the addition of the <vb:each> in templates...
Nobody is going to tell me that reading a database, parse the data to build an array, sending that array to the template and parsing it a second time is faster than bulding/formating the array and sending it in all one lump piece of data to the template.
<vb:each> is a lot faster then doing a ton of vB_Template::create() ... render() calls in a loop :)

Here is a little benchmark:
PHP Code:

require('./global.php');
require(
DIR '/includes/adminfunctions_template.php');

$vbulletin->templatecache['text_bit'] = compile_template('{vb:raw text}');
$vbulletin->templatecache['text'] = compile_template('{vb:raw textbits}');
$vbulletin->templatecache['text_foreach'] = compile_template('<vb:each from="textbits" value="text">{vb:raw text}</vb:each>');

// Benchmarking bit templates
$start microtime(true);
$textbits ='';
for (
$i 1$i 10000$i++)
{
    
$templater vB_Template::create('text_bit');
    
$templater->register('text''This is Text #' $i);
    
$textbits .= $templater->render();
}
$templater vB_Template::create('text');
$templater->register('textbits'$textbits);
$result1 trim($templater->render());
$end microtime(true);
header('Content-type: text/plain');
echo(
'Time taken for 10.000 Bit Templates: ' . ($end-$start) . "\n");

// Benachmarking <vb:each>
$start microtime(true);
$textbits = array();
for (
$i 1$i 10000$i++)
{
    
$textbits[] = 'This is Text #' $i;
}
$templater vB_Template::create('text_foreach');
$templater->register('textbits'$textbits);
$result2 trim($templater->render());
$end microtime(true);
echo(
'Time taken for 10.000 Array-Elements with <vb:each>: ' . ($end-$start) . "\n");

if (
$result1 == $result2)
{
    echo(
'Success - Both methods yielded the same result data');
}
else
{
    echo(
'Huh? Smth. went wrong, the results are not identical');
    echo(
"\n\n----\n$result1\n----\n$result2");



Paul M 05-19-2012 06:13 PM

Just in case you dont bother running that benchmark, here is the result on my local test environment

Time taken for 10.000 Bit Templates: 1.2209470272064
Time taken for 10.000 Array-Elements with <vb:each>: 0.010501146316528 (over 100x faster)
Success - Both methods yielded the same result data

and on my remote test server ;

Time taken for 10.000 Bit Templates: 1.3666188716888
Time taken for 10.000 Array-Elements with <vb:each>: 0.01978611946106 (over 70x faster)
Success - Both methods yielded the same result data

nhawk 05-19-2012 07:04 PM

I've already given in to the idea of having to create the menu additions in the database and have the update for that particular mod ready to be released. And those menu selections were always under the admin's control to begin with. Now they can just move them around a little more.

The bechmark isn't exactly what I was talking about. In the case of rendering bits templates I agree it's much faster.

But I see people using it something like this...

Code:

in PHP..
While $whatever...
{
      $whatever_each_array[] = xpartofdata;
}
$templater->register('whatever'. $whatever_each_array);

In template..
<ul>
<vb:each whatever_each>
        <li>{vb:raw whatever_array_part}</li>
</vb:each>
</ul>

When bulding the array as a static value and displaying it as a single value is much faster..
Code:

In PHP...
While $whatever....
{
        $static .=  '<li>' . $whatever_array_part . '</li>' . "\r\n";
}
templater->register('static', $static);

in template...
<ul>
{vb:raw static}
</ul>


Andreas 05-19-2012 07:44 PM

Quote:

Originally Posted by nhawk (Post 2330786)
But I see people using it something like this...

Code:

in PHP..
While $whatever...
{
      $whatever_each_array[] = xpartofdata;
}
$templater->register('whatever'. $whatever_each_array);

In template..
<ul>
<vb:each whatever_each>
        <li>{vb:raw whatever_array_part}</li>
</vb:each>
</ul>


Although that is a bit slower than hardcoding the HTML, this is the way it should be done as it separates the presentation from the business logic.

If the designer want's to do smth. complletely different from <ul> he can do that by simply modifying the template - with the list entries being generated in PHP he can't

kh99 05-19-2012 09:25 PM

Quote:

Originally Posted by Andreas (Post 2330764)
<vb:each> is a lot faster then doing a ton of vB_Template::create() ... render() calls in a loop :)

I'm curious, do you know why that is? Is it the time needed to create the objects?

AusPhotography 05-20-2012 06:14 AM

Quote:

Originally Posted by kh99 (Post 2330811)
I'm curious, do you know why that is? Is it the time needed to create the objects?

The render uses 'eval' 'nuff said

Kym

AusPhotography 05-20-2012 06:45 AM

This is very handy... https://vborg.vbsupport.ru/showthread.php?t=283123 (Thanks Andreas)

Also Scott's post on vb.com https://www.vbulletin.com/forum/show...56#post2295256

nhawk 05-20-2012 10:22 AM

Quote:

Originally Posted by Andreas (Post 2330789)
Although that is a bit slower than hardcoding the HTML, this is the way it should be done as it separates the presentation from the business logic.

If the designer want's to do smth. complletely different from <ul> he can do that by simply modifying the template - with the list entries being generated in PHP he can't

Even though I'm not a big fan of anything that increases processing time, I see your point. :)

And a note for any other coders that might want to add menus via DB addition rather than at installation.. Be sure you run build_language() after adding the navigation and phrase info. If you don't, your phrase won't appear in the menus.

EDIT: Another note.. The information that's the original topic of this thread gets added to the install XML when you export it. So, you just need to create the navigation links and export a new XML for the mod.

kh99 05-20-2012 12:03 PM

Quote:

Originally Posted by snoopytas (Post 2330878)
The render uses 'eval' 'nuff said

Kym

OK, but I ran this modified version of the benchmark:

PHP Code:

require('./global.php');
require(
DIR '/includes/adminfunctions_template.php');

$vbulletin->options['addtemplatename'] = 0;

$vbulletin->templatecache['text_bit'] = compile_template('{vb:raw text}');
$vbulletin->templatecache['text'] = compile_template('{vb:raw textbits}');
$vbulletin->templatecache['text_foreach'] = compile_template('<vb:each from="textbits" value="text">{vb:raw text}</vb:each>');

// Benchmarking bit templates
$start microtime(true);
$textbits ='';
for (
$i 1$i 10000$i++)
{
    
//$templater = vB_Template::create('text_bit');
    //$templater->register('text', 'This is Text #' . $i);
    //$textbits .= $templater->render();
    
$text 'This is Text #' $i;
    eval(
$vbulletin->templatecache['text_bit']);
    
$textbits .= $final_rendered;
}
$templater vB_Template::create('text');
$templater->register('textbits'$textbits);
$result1 trim($templater->render());
$end microtime(true);
header('Content-type: text/plain');
echo(
'Time taken for 10.000 Bit Templates: ' . ($end-$start) . "\n");

// Benachmarking <vb:each>
$start microtime(true);
$textbits = array();
for (
$i 1$i 10000$i++)
{
    
$textbits[] = 'This is Text #' $i;
}
$templater vB_Template::create('text_foreach');
$templater->register('textbits'$textbits);
$result2 trim($templater->render());
$end microtime(true);
echo(
'Time taken for 10.000 Array-Elements with <vb:each>: ' . ($end-$start) . "\n");

if (
$result1 == $result2)
{
    echo(
'Success - Both methods yielded the same result data');
}
else
{
    echo(
'Huh? Smth. went wrong, the results are not identical');
    echo(
"\n\n----\n$result1\n----\n$result2");



and I got these results:

Code:

Time taken for 10.000 Bit Templates: 0.072948932647705
Time taken for 10.000 Array-Elements with <vb:each>: 0.011199951171875
Success - Both methods yielded the same result data


vs. these for the original version:

Code:

Time taken for 10.000 Bit Templates: 1.542927980423
Time taken for 10.000 Array-Elements with <vb:each>: 0.011492967605591
Success - Both methods yielded the same result data


That's 6.5 times slower vs 134 times slower, and seems to indicate that eval() isn't the main offender.

Andreas 05-20-2012 12:12 PM

It's basically the overhead required for variable registration and object creation that makes rending templates in a loop pretty slow.

kh99 05-20-2012 12:41 PM

Yeah, I played around more and found that my times dropped from 1.5 to 0.7 just by not calling register_globals().

BirdOPrey5 05-20-2012 01:41 PM

Quote:

Originally Posted by Andreas (Post 2330753)
If it is a "static" link - yes, it should be added to the navigation table upon Add-on installation.
(Which will happen automatically if you have already added that link on your developement system, assigned in to the Add-on and exported the XML).

But if it's not a static link? I'm supposed to tell user's to do it themselves now because vBulletin thinks they want more control over their navbar? Respectfully, most user's do not want total control, they want things done for them.

I've come up with this code, it's not efficient but it works, I will work on efficiency-

nhawk I know you mentioned making a database change but I prefer to avoid db edits if possible.

This example adds a link to Quick Links
No phrase needed.

On navigation_tab_complete hook:

PHP Code:

//Quick Links Add in 4.2.0 Start
  
foreach ($tabdata AS $key => &$thistab)
  {
   if (
is_array($thistab['children']))
   {
    foreach (
$thistab['children'] AS &$ttab)
    {
     if (
$ttab['name'] == 'vbmenu_qlinks')
     {
       
$nl['root']  = $key;
       
$nl['type']  = 'link';
       
$nl['url']    = 'myfile.php';
       
$nl['title']  = 'Link Title';
       
$nl['name']  = 'custom_name_here';
       
$nl['children'] = 0;
       
$ttab['children'][] =  $nl;
     }
    }
   }
  }
//Quick Links Add 4.2.0 END 

Mind you that needs to be run for each new link which itself will likely be some kind of loop.

Andreas 05-20-2012 02:06 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2330964)
But if it's not a static link?

That is a problem :)

I do not know the exact ideas behind Navigation Manager , but I think it simply wasn't designed with dynamic links in mind as vBulletin itself (except vBulletin CMS) does not do that.

As I see it, there are currently three alternatives (of which none is realldy ideal):
  • Programatically create/update/delete links in navigation manager based on the Add-on data
    Pro: Full control over the links
    Con: Rather complicated management for the Add-on, might requires extensive changes to the logic
  • Don't create any links and leave it up to the user
  • Pro: Full control, no additional work the for Add-on author
    Con: A lot of work for the Administrator
  • Create links at runtime
    Pro: Fairly easy to do
    Con: Zero control over placement in Navigation Manager, code can be a little bit inefficient

IMHO the best solution would be if the Navigation Manager would offer "Dynamic Content" items which would just act as placeholders in ACP and are only being filled with content on the frontend when needed.
This would be easy to implement and maintain for Add-ons and would still give the Administrator the power to control placement, etc.

http://tracker.vbulletin.com/browse/VBIV-15123

nhawk 05-20-2012 03:19 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2330964)
But if it's not a static link? I'm supposed to tell user's to do it themselves now because vBulletin thinks they want more control over their navbar? Respectfully, most user's do not want total control, they want things done for them.

I've come up with this code, it's not efficient but it works, I will work on efficiency-

nhawk I know you mentioned making a database change but I prefer to avoid db edits if possible.

This example adds a link to Quick Links
No phrase needed.

On navigation_tab_complete hook:

PHP Code:

//Quick Links Add in 4.2.0 Start
  
foreach ($tabdata AS $key => &$thistab)
  {
   if (
is_array($thistab['children']))
   {
    foreach (
$thistab['children'] AS &$ttab)
    {
     if (
$ttab['name'] == 'vbmenu_qlinks')
     {
       
$nl['root']  = $key;
       
$nl['type']  = 'link';
       
$nl['url']    = 'myfile.php';
       
$nl['title']  = 'Link Title';
       
$nl['name']  = 'custom_name_here';
       
$nl['children'] = 0;
       
$ttab['children'][] =  $nl;
     }
    }
   }
  }
//Quick Links Add 4.2.0 END 

Mind you that needs to be run for each new link which itself will likely be some kind of loop.

I thought of doing it that way, an actually had it done that way. But then there's no control by the admin as to where it goes (as pointed out by Andreas) and I changed to the DB write.

The advantage of doing it in the DB is the admin can move it around to any menu once it's created. After working with it a bit, I found management really isn't difficult. It's only a couple of DB writes at application type creation (in my mod) and then I'm done with it. No need to parse out a special template or anything else in vB 4.2.

And the nice thing is that when the product is uninstalled, the navigation and phrase info gets deleted like it should.

Andreas 05-20-2012 03:56 PM

Quote:

The advantage of doing it in the DB is the admin can move it around to any menu once it's created. After working with it a bit, I found management really isn't difficult. It's only a couple of DB writes at application type creation (in my mod) and then I'm done with it. No need to parse out a special template or anything else in vB 4.2.

And the nice thing is that when the product is uninstalled, the navigation and phrase info gets deleted like it should.
Keep in mind that links created this way will be deleted when your Add-on is upgraded:
http://tracker.vbulletin.com/browse/VBIV-14959

To avoid this you would have to do some trickery in your installation code.

If anyone feels that this issue is important, please vote for it :)

BirdOPrey5 05-20-2012 07:13 PM

Quote:

Originally Posted by Andreas (Post 2331012)
Keep in mind that links created this way will be deleted when your Add-on is upgraded:
http://tracker.vbulletin.com/browse/VBIV-14959

To avoid this you would have to do some trickery in your installation code.

If anyone feels that this issue is important, please vote for it :)

Voted... But I do think it's working logically now, consistent with plugins and templates. Seems like nav elements should have a special setting though.

Andreas 05-20-2012 09:03 PM

Consistent with Plug-ins, yes - but not consistent with how it worked in previous vBulletin versions:

In previous versions Add-ons usually added their links into the Navbar by rendering their own templates on a certain template Hook.

If the Administrator modified those templates (eg. if he added another link), an upgrade of the Add-on would not overwrite this modification - the link would still be there after an upgrade.

Most items (Settings, Cron-Jobs, FAQ, Admin-Help, etc.) do have a volatile flag to handle "custom items" on upgrades, and this is what is missing here.

Badshah93 05-20-2012 09:05 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2330964)
But if it's not a static link? I'm supposed to tell user's to do it themselves now because vBulletin thinks they want more control over their navbar? Respectfully, most user's do not want total control, they want things done for them.

I've come up with this code, it's not efficient but it works, I will work on efficiency-

nhawk I know you mentioned making a database change but I prefer to avoid db edits if possible.

This example adds a link to Quick Links
No phrase needed.

On navigation_tab_complete hook:

PHP Code:

//Quick Links Add in 4.2.0 Start
  
foreach ($tabdata AS $key => &$thistab)
  {
   if (
is_array($thistab['children']))
   {
    foreach (
$thistab['children'] AS &$ttab)
    {
     if (
$ttab['name'] == 'vbmenu_qlinks')
     {
       
$nl['root']  = $key;
       
$nl['type']  = 'link';
       
$nl['url']    = 'myfile.php';
       
$nl['title']  = 'Link Title';
       
$nl['name']  = 'custom_name_here';
       
$nl['children'] = 0;
       
$ttab['children'][] =  $nl;
     }
    }
   }
  }
//Quick Links Add 4.2.0 END 

Mind you that needs to be run for each new link which itself will likely be some kind of loop.

does 'name' key exist in tabdata[children] array, because when i print_r the tabdata array i did not find a word called "name" anywhere.

Well i liked vb 4.2.0 navigation manager and specially for my new mod. Yes i still have to create one plugin which i was doing in earlier version also but i won't have to create new template for it to use vb:each function.

i am creating a new mod which has one tab and under which there are 5 menu by default. (which i will create it through navigation manager)
there are 3 menu who's links are not fixed, it changes for each usergroup, so i will be creating array of links for those menus which i was for doing in earlier version also.

i don't know how others are going to place their dynamic links inside menu, but i will be doing this way

Plugin Hook: set_navigation_tab_main
PHP Code:


if (THIS_SCRIPT == 'myscript')
{

$rootid $roots['mytabname'];   
$x build_navigation_list(true$rootidfalse); // building mytabname list only

// An Array with menu name = $key and value = links array 
(ex: array([menu1] => array([0]=> array('title' => 'google''url' => 'google.com'
[
1]=> array('title' => 'vbulletin''url' => 'vbulletin.com')) [menu2] => (link array for menu2))

foreach (
$array AS $menuname => $linkarray)
{

$menuchild $x["$rootid"]["links"]["$menuname"]["navid"];

$tabs["$rootid"][children]["$menuchild"][children] = array_merge($tabs["$rootid"][children]["$menuchild"][children], $linkarray);

}



Benefits of this method:

1) admin can add new menu inside "mytabname" easily through navigation manager
2) admin can add new links inside any menu. (even those menu which have dynamic links)
3) admin can change displayorder, title of any menu.
4) admin can change title of any links through navigation. (for dynamic links through phrase manager)
5) it hardly effects overall performance. (.1 extra second)

nhawk 05-21-2012 11:07 AM

Quote:

Originally Posted by Andreas (Post 2331012)
Keep in mind that links created this way will be deleted when your Add-on is upgraded:
http://tracker.vbulletin.com/browse/VBIV-14959

To avoid this you would have to do some trickery in your installation code.

If anyone feels that this issue is important, please vote for it :)

Voted.

But a workaround for that is to create another product that only contains navigation items. Then the navigation items don't get overwritten if the main product is updated.

Andreas 05-21-2012 11:29 AM

Yep, that would work but doesn't seem that user friendly ;)

Another workaround would be to do some installation code trickery to add already existing items to the XML data.

nhawk 05-21-2012 12:05 PM

Quote:

Originally Posted by Andreas (Post 2331225)
Yep, that would work but doesn't seem that user friendly ;)

Another workaround would be to do some installation code trickery to add already existing items to the XML data.

I agree it's not that user friendly, but it seemed to be the most fool-proof way of doing it.

The funny thing is (if I'm reading that bug report right) if an admin adds 10 or 20 navigation tabs/menu selections to a stock vB installation using the vBulletin product as the parent, and then updates vB, all of those changes will be lost with the upgrade.

That's a bug to me! The admin will have to re-insert the changes he made each time he upgrades vB.

So that's not an improvement request.

AusPhotography 05-23-2012 06:52 AM

This is Paul M's blog on how to use the Navigation Manager

https://www.vbulletin.com/forum/entr...amp-Navigation

Kym

Paul M 05-23-2012 08:42 AM

Quote:

Originally Posted by nhawk (Post 2331232)
The funny thing is (if I'm reading that bug report right) if an admin adds 10 or 20 navigation tabs/menu selections to a stock vB installation using the vBulletin product as the parent, and then updates vB, all of those changes will be lost with the upgrade.

They will not, the upgrade process does not remove any tabs/menus/links belonging to the core 'vbulletin' product.

nhawk 05-23-2012 01:19 PM

Quote:

Originally Posted by Paul M (Post 2331863)
They will not, the upgrade process does not remove any tabs/menus/links belonging to the core 'vbulletin' product.

Hmm... but it will for other products? Odd that's not considered a bug.

But, I'm not the one who classifies these things. :D

Paul M 05-23-2012 02:15 PM

Not odd at all - the core isnt an add-on, other products are.

Paul M 05-23-2012 05:48 PM

A few points involving 4.2.1

Dont use the navbar_after_links or navbar_after_sublinks template hooks.
They were supposed to have been removed, and will probably go in 4.2.1.

These two hooks are likely to disappear as well - collapse_navigation_state, expand_navigation_state

The reason they existed was because the bit definitions for the state field were not defined in the vb bitfield file (long story), so the hooks were there to cope with any custom ones. However, another change due in 4.2.1 is to convert the state field to use bitfields defined in the vb bitfield file, so it will not be necessary to use any hooks to add to them.

Also, 4.2.1 should see all the Nav Man functions moved out of functions.php into their own file, making it easier to find, update or replace them in the future.

Boofo 05-23-2012 05:54 PM

Quote:

Originally Posted by Paul M (Post 2332012)
A few points involving 4.2.1

Dont use the navbar_after_links or navbar_after_sublinks template hooks.
They were supposed to have been removed, and will probably go in 4.2.1.

These two hooks are likely to disappear as well - collapse_navigation_state, expand_navigation_state

The reason they existed was because the bit definitions for the state field were not defined in the vb bitfield file (long story), so the hooks were there to cope with any custom ones. However, another change due in 4.2.1 is to convert the state field to use bitfields defined in the vb bitfield file, so it will not be necessary to use any hooks to add to them.

Also, 4.2.1 should see all the Nav Man functions moved out of functions.php into their own file, making it easier to find, update or replace them in the future.


What hooks do we use then if we want to add our own sublinb menu? I have one that uses the vb:each to get the post days for searching and I can't use the navigation manager to add that sub-menu.

BirdOPrey5 05-23-2012 05:57 PM

For those who may be looking on just how to change the default page off of the Activity Stream and back to the CMS or Forum check out this thread: https://www.vbulletin.com/forum/show...t-Tab-in-4-2-0

odln018 05-23-2012 06:06 PM

I'm wanting to create a tab called "Special Access", with sub-links that will go to my library, jukebox, etc. There is not any base page to associate it with. It's just a tab with the sublinks. How the heck do I do this?

Lynne indicated I " will require a plugin to define that tab as active.:

Could someone please assist with this?

BirdOPrey5 05-23-2012 06:44 PM

If there's no page what page will show when someone clicks on it?

odln018 05-23-2012 07:00 PM

That's just where I'm messed up, I don't know what kind of page I can make or place there.

Something tells me I'm not going to be able to do this.

Paul M 05-23-2012 07:05 PM

Its perfectly possible to have a tab with no target url defined, so its just to present a set of links.

However, bear in mind that no link will mean the system redirects you to your site default, so you may want to direct it (the tab) to something like forum.php.

nhawk 05-23-2012 07:10 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2332039)
If there's no page what page will show when someone clicks on it?

I've enabled the bug report forms for registered users on my site. Go there and click on the navtab. You'll get a dropdown menu. I think that's what he's talking about.

Quote:

Originally Posted by Paul M (Post 2332048)
Its perfectly possible to have a tab with no target url defined, so its just to present a set of links.

If a dropdown menu with links is what you're talking about.. Please do tell how?

I've tried everything I can think of with the navigation manager with no success.


All times are GMT. The time now is 07:48 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01992 seconds
  • Memory Usage 2,004KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (10)bbcode_code_printable
  • (6)bbcode_php_printable
  • (27)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete