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)

TheLastSuperman 05-29-2012 04:44 PM

Very good discussion and imo the first post and info that follows by everyone else makes this worthy of being a Article! I moved this thread here to the articles forum, there is a 7 day redirect link in programming discussions and normally I don't do redirects but just in case some look there first in the next few days ;).

Boofo 05-29-2012 04:48 PM

Try commenting out the $result line at the bottom. I don't know if that will work in that hook.

Altari 05-29-2012 05:36 PM

Quote:

Originally Posted by Boofo (Post 2334356)
Try commenting out the $result line at the bottom. I don't know if that will work in that hook.

I don't really know what did u expect but of course this code with $result = commented, do nothing :
Code:

global $show;
if ($show['member'] == TRUE)
{
    $userid = vB::$vbulletin->userinfo['userid'];
    $lien_messujets = array(
        'name' => 'rescue_messujets',
        'navtype' => 'link',
        'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread',
        'active' => 1,
        'productid' => 'rescue',
        'text' => 'Mes sujets',
    );
    //$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets;
    unset($userid);
}

(tested in build_navigation_array and navigation_tab_complete, with and without the comment)

Badshah93 05-29-2012 05:48 PM

Quote:

Originally Posted by Altari (Post 2334346)
Hello,

Thank you for your help,
But this doesn't work better : I added the global show and change template hook, but nothing happen. I use VBOptimise(?), but i flushed the cache, cleared system cache etc... Nothing works like that :(

Anyway, i'm just trying to add this to start, and it doesn't work :
PHP Code:

global $show;
if (
$show['member'] == TRUE

    
$lien_messujets = array( 
        
'name' => 'rescue_messujets'
        
'navtype' => 'link'
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread',
        
'active' => 1
        
'productid' => 'rescue'
        
'text' => 'Mes sujets'
    ); 
    
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets;



Try This Code

Hook: build_navigation_array
Code:

PHP Code:

if (vB::$vbulletin->userinfo['userid']) 
{
$lien_messujets = array(  
        
'name' => 'rescue_messuje',  
        
'navtype' => 'link',  
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread'
        
'active' => 1,  
        
'text' => 'Message',
        
'productid' => 'vbulletin',  
    );  

$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messuje'] = $lien_messujets;


You can replace vbulletin with your product id but make sure that product is enabled otherwise link will not be shown.

nhawk 05-29-2012 06:36 PM

A while back I commented about using the database method for adding things to the navigation menu and nobody has shown how to do that.

So, here's my method broken out and heavily commented so it's easy to understand....

Code:

// ########## CREATE NEW NAVIGATION ITEMS ##########
require_once(DIR . '/includes/adminfunctions_language.php');

$username = $vbulletin->userinfo['username'];
$dateline = TIMENOW;

$product = 'yourproductname';                                // <<<< CHANGE TO YOUR PRODUCT NAME
$version = '1.0.0';                                        // <<<< CHANGE TO YOUR PRODUCT VERSION
$name = 'yourmenu_name';                                // <<<< CHANGE TO WHAT YOU WANT TO NAME YOUR MENU
$varname = 'vb_navigation_menu_' . $name . '_text';        // <<<< VALID CHOICES:
                                                        //        FOR MENUS:        vb_navigation_menu_' . $name . '_text'
                                                        //        FOR TABS:        vb_navigation_tab_' . $name . '_text'
                                                        //        FOR LINKS:        vb_navigation_link_' . $name . '_text'

$text = 'Text to Display';                        // <<<< CHANGE TO THE TEXT YOU WANT DISPLAYED IN THE MENU
$type = 'menu';                                        // <<<< CHANGE TO link OR tab TO CREATE OTHER TYPES
$url = '';                                        // <<<< URL IS USED FOR LINK OR TAB TYPES
$fieldname = 'global';                                // <<<< PHRASE GROUP NAME
$active = 1;                                        // <<<< 1 = SHOWN, 0 = HIDDEN
$usetabid = 0;                                        // <<<< 1 = APPEND TABID TO LINK, 0 = DON'T APPEND TAB ID
$edited = 0;                                        // <<<< SHOULD BE 0 IF NEW, 1 IF EDITED
$protected = 1;                                        // <<<< 1 = PROTECT FROM DELETE, 0 = ALLOW DELETE
$order = 20;                                        // <<<< DISPLAY ORDER
$parent = 'vbtab_forum';                        // <<<< PARENT CAN BE A tab IF A MENU, A tab OR A menu IF A LINK
$permission = 'searchbuttons';                        // <<<< CAN BE A VB PERMISSION OR A $SHOW['xyz'] VALUE
$scripts = '';                                        // <<<< SCRIPT FOR WHICH A TAB WILL BE DISPLAYED AS ACTIVE TAB
$language = '-1';                                // <<<< DEFAULT = -1 OTHERWISE LANGUAGE ID NUMBER

$vbulletin->db->query_write("
        REPLACE INTO " . TABLE_PREFIX . "navigation (name, productid, navtype, fieldname, state, displayorder, parent, scripts, showperm, url, version, username, dateline)
        VALUES('" . $name . "',
                '" . $product . "',
                '" . $type ."',
                '" . ($active ? NAV_ACTIVE : 0) . "' | '" . ($edited ? NAV_EDITED : 0) . "' | '" . ($protected ? NAV_PROTECTED : 0) . "' | '" . ($usetabid ? NAV_USETABID : 0) . "',
                '" . $order . "',
                '" . $parent . "',
                '" . $scripts . "',
                '" . $permission . "',
                '" . $url . "',
                '" . $version . "',
                '" . $username . "',
                '" . $dateline . "')
        ");

$vbulletin->db->query_write("
        REPLACE INTO " . TABLE_PREFIX . "phrase (varname,languageid,fieldname,text,product,username,dateline,version)
        VALUES('" . $varname . "',
                '" . $language . "',
                '" . $fieldname . "',
                '" . $text . "',
                '" . $product . "',
                '" . $username . "',
                '" . $dateline . "',
                '" . $version . "')
        ");

build_language();        // <<<< IMPORTANT - NEW ITEMS WON'T DISPLAY WITHOUT THIS


Boofo 05-29-2012 06:47 PM

What hook do they run it in?

Altari 05-29-2012 06:54 PM

Quote:

Originally Posted by Badshah93 (Post 2334379)
Try This Code
...

Hello,

Thank you for your help.
You code works, but only for one link. When i want to add more than 1 link, only the last is displayed.
Tested with this code :
PHP Code:

if (vB::$vbulletin->userinfo['userid']) 
{
$userid vB::$vbulletin->userinfo['userid'];
$lien_messujets = array(  
        
'name' => 'rescue_messujets',  
        
'navtype' => 'link',  
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread'
        
'active' => 1,  
        
'text' => 'Mes sujets',
        
'productid' => 'vbulletin',  
    );  
$lien_mesmessages = array( 
    
'name' => 'rescue_mesmessages'
    
'navtype' => 'link'
    
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Post&showposts=1',
    
'active' => 1
    
'productid' => 'vbulletin'
    
'text' => 'Mes messages'
); 
$lien_mesannonces = array( 
    
'name' => 'rescue_commu_annonces'
    
'navtype' => 'link'
    
'url' => '{options.toppath}member.php?u='.$userid.'&tab=afficher_annonces',
    
'active' => 1
    
'productid' => 'vbulletin'
    
'text' => 'Mes annonces'
); 
    
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets;
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_commu_annonces'] = $lien_mesannonces;
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_mesmessages'] = $lien_mesmessages;
unset(
$userid);



nhawk 05-29-2012 06:57 PM

Quote:

Originally Posted by Boofo (Post 2334409)
What hook do they run it in?

It can be run anywhere, in PHP code, or any other hook they want.

I use it in both PHP code for dynamic menus added by an admin from inside a mod and in the admin_options_processing_build hook for adding menus defined by the settings group for a mod.

If you use it in the admin_options_processing_build hook, add a !$settings['dummyvar'] condition at the beginning of the code and set $settings['dummyvar'] to 1 at the end of the code so it only runs once when the settings are updated.

Of course the variables would have to be gotten from the $settings['xyz'] values from the mod settings and/or some hard coded into the plugin.

EDIT: The advantage to using the database for menu items is there aren't any plugins required once the menu is created. vB itself will generate them for you at the proper time. That should be a BIG HINT for the discussion above and below this post that's revolving around a plugin to create a menu that on the surface appears to be a fixed menu that can accept variables (ie: {userinfo.userid} ). Create it once in settings or some other method and forget about it until it needs to change. Which I don't see that happening very often.

Code:

{options.toppath}search.php?do=finduser&amp;userid={userinfo.userid}&amp;starteronly=1&amp;contenttype=vBForum_Thread
;)

I do not suggest the database method for navigation items where the displayed text for the navigation item changes frequently (the name of the item ie: Forum or What's New) or where the link is not a fixed link with variables.

Badshah93 05-29-2012 07:05 PM

Quote:

Originally Posted by Altari (Post 2334413)
Hello,

Thank you for your help.
You code works, but only for one link. When i want to add more than 1 link, only the last is displayed.

Try this code

PHP Code:

if (vB::$vbulletin->userinfo['userid'])  

$userid vB::$vbulletin->userinfo['userid']; 
$lien_messujets = array(   
        
'name' => 'rescue_messujets',   
        
'navtype' => 'link',   
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread',  
        
'active' => 1,   
        
'text' => 'Mes sujets'
        
'productid' => 'vbulletin',
        
'navid' => 1   
    
);   
$lien_mesmessages = array(  
    
'name' => 'rescue_mesmessages',  
    
'navtype' => 'link',  
    
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Post&showposts=1',
    
'active' => 1,  
    
'productid' => 'vbulletin',  
    
'text' => 'Mes messages',
    
'navid' => 2  
);  
$lien_mesannonces = array(  
    
'name' => 'rescue_commu_annonces',  
    
'navtype' => 'link',  
    
'url' => '{options.toppath}member.php?u='.$userid.'&tab=afficher_annonces'
    
'active' => 1,  
    
'productid' => 'vbulletin',  
    
'text' => 'Mes annonces',
    
'navid' => 3  
);  
     
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_commu_annonces'] = $lien_mesannonces
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_mesmessages'] = $lien_mesmessages
unset(
$userid); 


compare it with your code, you will know why it was not working earlier.

Altari 05-29-2012 07:42 PM

Quote:

Originally Posted by Badshah93 (Post 2334417)
...

Awww that works perfectly, thank you !
For guys who read : Add an id...

Andreas 05-29-2012 09:22 PM

Quote:

Originally Posted by Altari (Post 2334427)
Awww that works perfectly, thank you !
For guys who read : Add an id...

... a unique ID or you will run into problems sooner or later ;)

Badshah93 05-30-2012 03:51 AM

Quote:

Originally Posted by Andreas (Post 2334465)
... a unique ID or you will run into problems sooner or later ;)

chances are very less, because all the links inside menu generated through navigation manager has id in range of (20 - 50 +), so one can use any id between 1-20 for links inside menu. (per menu).

A higher number will be much better (ex: 1001)

OR

Get the last navid of link in menu.

PHP Code:

$lastnavid array_pop(array_keys($result['vbtab_forum']['links']['vbmenu_qlinks']['links']));
$lastnavid $result['vbtab_forum']['links']['vbmenu_qlinks']['links'][$lastnavid]['navid']; 

So, last code which i gave to one of the user will be like this

PHP Code:

if (vB::$vbulletin->userinfo['userid'])  

$userid vB::$vbulletin->userinfo['userid']; 
$lastnavid array_pop(array_keys($result['vbtab_forum']['links']['vbmenu_qlinks']['links']));
$lastnavid $result['vbtab_forum']['links']['vbmenu_qlinks']['links'][$lastnavid]['navid'];

$lien_messujets = array(   
        
'name' => 'rescue_messujets',   
        
'navtype' => 'link',   
        
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Thread',  
        
'active' => 1,   
        
'text' => 'Mes sujets'
        
'productid' => 'vbulletin',
        
'navid' => $lastnavid++   
    );   
$lien_mesmessages = array(  
    
'name' => 'rescue_mesmessages',  
    
'navtype' => 'link',  
    
'url' => '{options.toppath}search.php?do=finduser&userid='.$userid.'&starteronly=1&contenttype=vBForum_Post&showposts=1',
    
'active' => 1,  
    
'productid' => 'vbulletin',  
    
'text' => 'Mes messages',
    
'navid' => $lastnavid++ 
);  
$lien_mesannonces = array(  
    
'name' => 'rescue_commu_annonces',  
    
'navtype' => 'link',  
    
'url' => '{options.toppath}member.php?u='.$userid.'&tab=afficher_annonces'
    
'active' => 1,  
    
'productid' => 'vbulletin',  
    
'text' => 'Mes annonces',
    
'navid' => $lastnavid++  
);  
     
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_messujets'] = $lien_messujets
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_commu_annonces'] = $lien_mesannonces
$result['vbtab_forum']['links']['vbmenu_qlinks']['links']['rescue_mesmessages'] = $lien_mesmessages
unset(
$userid); 



Omegatron 05-30-2012 06:09 PM

What I need to know is how to use the $vbulletin options in a url in the navigation manager

Paul M 05-30-2012 09:14 PM

{options.optionname}

AusPhotography 05-30-2012 10:31 PM

Quote:

Originally Posted by Paul M (Post 2334852)
{options.optionname}

Can we have a Article outlining what objects are available ?
I know of...
  • {options.__}
  • {session.__}
  • {userinfo.__}
What else is available?
Can we have custom objects?

Thanks!

Kym

Edit: Found the answer in the code.
See: function process_navigation_linkvars($url) in ./includes/functions.php :D
Anything in $GLOBALS or in $vbulletin->object where object is options, userinfo etc.

Merenguista 05-31-2012 10:47 AM

1- I want add a new Tab, what shoup i put in Tab Script(s) ?

2- I want add a menu and link only for Users Awaiting Moderation, what shoud i put in Show Permission Name ?

AusPhotography 06-01-2012 03:00 AM

We use Photopost vBgallery and it runs in a different root path to the forum...
eg: ./forurm vs ./gallery
As a result any relative paths in the Tabs fail when in the Gallery unless you do some edits in the Navigation Manager.

I've built an interim product file for vBgallery 3.01 that has support for the new vB4.2.0 navigation. (I can't post it due to (c) reasons).

Chuck @ Photopost has my code and will release an update for vBgallery (soon-ish I hope)

nhawk 06-01-2012 08:20 AM

Quote:

Originally Posted by Merenguista (Post 2335018)
1- I want add a new Tab, what shoup i put in Tab Script(s) ?

The name of the php script that makes the tab the active tab. The script must supply it's name with this code...

Code:

define('THIS_SCRIPT', 'thenameofthescript');
Quote:

Originally Posted by Merenguista (Post 2335018)
2- I want add a menu and link only for Users Awaiting Moderation, what shoud i put in Show Permission Name ?

I don't think there's a standard $show variable for that usergroup so you would need to create a custom one in a plugin. Call it something like... uamod ...and put that in the Show Permission Name. The create a plugin with this code...

Code:

if(is_member_of($vbulletin->userinfo,3))
{
        $show['uamod'] = true;
}

That code can be used in either the 'parse_templates' or the 'process_templates_complete' hook.

cjwinternet 07-06-2012 08:39 PM

<removed>

KGodel 07-21-2012 01:12 AM

Hey guys. I am having an issue with some Show Permissions. I have successfully gotten some working, creating the hook for each special usergroup, however when I add them together, so say I want usergroups X, Y, and Z to see a link, each having a separate $show variable in the hook I have created, when I combine them such as "showx.showy.showz" this seems to make the link appear only if a user is in ALL groups. Is there a character I am supposed to use aside from the dot to create an "or" combination versus and "and" combination? Thanks!

Paul M 07-21-2012 11:32 AM

Joining them with a dot in the permissions box means all of them must be true.
There isnt any way to do an OR within the box, you would need to do it a hook and assign the result to another show variable.

nasko 08-21-2012 06:32 AM

Can someone, pleace, tell mi how to make these steps because I'm new in Vbulletin and I had installed some Mod but the NavBar totaly screwed up...
Quote:

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

Robbed 10-08-2012 07:59 PM

Quick question, my navigation works for all plugins installed but one.

I doubt it will be updated so any help would be appreciated. This application sits outside of the forum path and the navigation menu doesn't show up.

Any code I can add to templates or the php file so it shows the navbar menu then i can disable the navbar plugin for this application.

Thanks

Nelson58 01-17-2014 04:33 PM

I am using Navigation Manager with an enhancement from DBTech
https://vborg.vbsupport.ru/showthread.php?t=274972

I want to change the appearance (background and text) of just one or two tabs to make them stand out.
(hover and non hover)

How can I do this please?

ozzy47 01-17-2014 05:02 PM

Answered in the other thread you started.

Elenna 01-31-2014 07:43 PM

I have created a tab via the Nav Manager that links directly to an article.

That link works just fine; however, when I click on the "regular" Articles tab (the standard one, that links to content.php), my users that are not logged in get an Access Denied message.

I have checked and the Not Logged In usergroup has read access to CMS.

Any ideas?

Elenna 02-02-2014 04:24 AM

1 Attachment(s)
I re-did my site and the problem, above, is fixed.

Now I have another question. :)

I am using the Navication manager in 4.2.2 and adding in some Tab sub-menus. My Tabs that have a drop-down menu attached are 1px taller than the ones that do not have sub-menus. :( I see where I can edit the tab template, but I'm not sure what to change.

Edit: Another possibility is that the Tab with the drop-down menu is looking at the stylevar or CSS height of the "selected" tab, because they both appear to be 1px larger along the bottom.

I am attaching a screenshot of what I mean.

ozzy47 02-02-2014 10:16 AM

That is a issue that is related to your custom style, you would need to ask the skin designer what the issue is.

Elenna 02-02-2014 02:36 PM

Thanks! It looks like we set the navtab border color to the same as the background, so it disappeared.

It looks like the "issue" is that the Tab with the drop-down isn't getting the border applied to it, even with the default style.

friendlymela 07-21-2015 03:48 PM

how can i add fb group link in navigation ?

BirdOPrey5 07-22-2015 07:48 PM

In Admin CP go to Settings -> Navigation Manager.

If you want a new tab click the Add Tab button at the bottom.

If you want to make it a sub-menu option of an existing tab go to the drop down menu for that tab and choose the "Add Link" option.

In either case on the next screen paste in the URL of the Facebook Group.

Set any other settings you want.

Save Changes.


All times are GMT. The time now is 01:05 AM.

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.01603 seconds
  • Memory Usage 1,913KB
  • 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
  • (5)bbcode_code_printable
  • (6)bbcode_php_printable
  • (12)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
  • (31)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