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...


All times are GMT. The time now is 10:35 PM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01797 seconds
  • Memory Usage 1,830KB
  • 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
  • (3)bbcode_code_printable
  • (4)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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