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)

Boofo 05-24-2012 11:44 AM

Quote:

Originally Posted by snoopytas (Post 2332175)
Please see:
https://vborg.vbsupport.ru/showthread.php?t=283146
and
https://www.vbulletin.com/forum/show...t-Tab-in-4-2-0

The way I'm doing it is via a <navigation> section of my product files and only setting $show variables to control their display.

The Navigation Manager won't accept variables, though, and that is the issue I am having. I have a Search Posts sub-link menu that uses a setting to get the days.

Code:

7,14,30,120,180
etc...

I then use vb:each in the template to have it build the menu with the days links:

Code:

Posts for Last 7 Days
Posts for Last 14 Days
Posts for Last 30 Days
Posts for Last 120 Days
Posts for Last 180 Days

etc...

You can't do that in the Navigation Manager so I need to be able to add that sub-link where the New Posts link (below the navtabs) is now. Without the template hooks, I'm screwed.

nhawk 05-24-2012 02:01 PM

Quote:

Originally Posted by Boofo (Post 2332291)
The Navigation Manager won't accept variables, though, and that is the issue I am having. I have a Search Posts sub-link menu that uses a setting to get the days.

Code:

7,14,30,120,180
etc...

I then use vb:each in the template to have it build the menu with the days links:

Code:

Posts for Last 7 Days
Posts for Last 14 Days
Posts for Last 30 Days
Posts for Last 120 Days
Posts for Last 180 Days

etc...

You can't do that in the Navigation Manager so I need to be able to add that sub-link where the New Posts link (below the navtabs) is now. Without the template hooks, I'm screwed.

Like this?

http://snogssite.com/tempdown/likethis.jpg

1) Add a menu to the forum tab.
2) Add links to the menu.

In the example shown I didn't disable the original New Posts link.. you might want to do that too. :D

You can do this manually, in the install file for your mod, in a php file, in a plugin using the database, or I'm pretty sure dynamically in a plugin.

I'm using the database method for items that don't change frequently. The best place I've found for something that comes from a settings page is to use the admin_options_processing hook and add/modify the navigation items in the database.

Boofo 05-24-2012 04:36 PM

Yes, it is looks that but I use vb:each to get each link from the settings. I don't add them one by one. This is what I use in the template (wrapped in a vb:each) to get it to make the menu:

Code:

<li><a href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Post&amp;days={vb:raw postdays}">{vb:rawphrase boofo_posts_from_last_x_days, {vb:raw postdays}}</a></li>

nhawk 05-24-2012 05:34 PM

Quote:

Originally Posted by Boofo (Post 2332382)
Yes, it is looks that but I use vb:each to get each link from the settings. I don't add them one by one. This is what I use in the template (wrapped in a vb:each) to get it to make the menu:

Code:

<li><a href="search.php?{vb:raw session.sessionurl}do=getdaily&amp;contenttype=vBForum_Post&amp;days={vb:raw postdays}">{vb:rawphrase boofo_posts_from_last_x_days, {vb:raw postdays}}</a></li>

Since the settings are where the number of days are contained, get the template out of your head. It's not needed anymore. :)

Put the links in the navigation table and the phrases for those links in the phrase table via the admin_options_processing hook once and you're done.

The only time they would need to be updated is if the settings change and then you just update them via the same hook.

Badshah93 05-24-2012 05:45 PM

Quote:

Originally Posted by Boofo (Post 2332291)
The Navigation Manager won't accept variables, though, and that is the issue I am having. I have a Search Posts sub-link menu that uses a setting to get the days.

Code:

7,14,30,120,180
etc...

I then use vb:each in the template to have it build the menu with the days links:

Code:

Posts for Last 7 Days
Posts for Last 14 Days
Posts for Last 30 Days
Posts for Last 120 Days
Posts for Last 180 Days

etc...

You can't do that in the Navigation Manager so I need to be able to add that sub-link where the New Posts link (below the navtabs) is now. Without the template hooks, I'm screwed.

Try This Method

Hook: navigation_tab_complete

PHP Code:

if ($root == 'vbtab_forum')
{
$days = array(7,14,30,120,180);

$tabforumid $roots['vbtab_forum'];
$children = array();
foreach (
$days AS $day)
{
$children[] = array('title' => 'Post For Last ' 
$day ' Days''url' => 'search.php?do=process&searchdate=' $day'type' => 'link''root' => $tabforumid);  
}

$tabdata["$tabforumid"][children][] = array(
'root' => $tabforumid,
'type' => 'menu',
'title' => 'New Posts',
'children' => $children
);




Boofo 05-24-2012 06:00 PM

Yes, that worked., although it throws it as the end of the links instead of at the beginning where it needs to be. Plus I has more items in the menu too, but this is close.

nhawk 05-24-2012 06:05 PM

I'm really curious why people are so resistant to putting their navigation items in the database. It's easy to do and it only needs to be done once (or any time there's a change in the settings). And then the menu is handled by vB without the use of a plugin.

Badshah93 05-24-2012 06:07 PM

Quote:

Originally Posted by Boofo (Post 2332425)
Yes, that worked., although it throws it as the end of the links instead of at the beginning where it needs to be. Plus I has more items in the menu too, but this is close.

use array_slice, array_merge to adjust position

Boofo 05-24-2012 06:09 PM

Quote:

Originally Posted by nhawk (Post 2332426)
I'm really curious why people are so resistant to putting their navigation items in the database. It's easy to do and it only needs to be done once (or any time there's a change in the settings). And then the menu is handled by vB without the use of a plugin.

Because why make unnecessary queries when you don't have to?

nhawk 05-24-2012 06:11 PM

Quote:

Originally Posted by Boofo (Post 2332428)
Because why make unnecessary queries when you don't have to?

The only query you're making is when you add to the database when you save settings. The rest is already done by vB.


All times are GMT. The time now is 04:25 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.01399 seconds
  • Memory Usage 1,762KB
  • 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
  • (8)bbcode_code_printable
  • (1)bbcode_php_printable
  • (7)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