vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   $threadid in navbar? (https://vborg.vbsupport.ru/showthread.php?t=248007)

ThorstenA 08-04-2010 08:29 PM

$threadid in navbar?
 
How can I work with $threadid in the navbar template?

Lynne 08-05-2010 12:00 AM

You would have to preregister the variable for use in that template. Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide

ThorstenA 08-05-2010 08:54 AM

Thanks! This is what worked for me:

On showthread.php replace
PHP Code:

$navbar render_navbar_template($navbits); 

with
Code:

        $templater = vB_Template::create('navbar');

        // Resolve the root segment
        $templater->register('bbmenu', $vbulletin->options['bbmenu']);

        $templater->register('ad_location', $GLOBALS['ad_location']);
        $templater->register('foruminfo', $GLOBALS['foruminfo']);
        $templater->register('navbar_reloadurl', $GLOBALS['navbar_reloadurl']);
              $templater->register('thread', $thread);
        $templater->register('navbits', $navbits);
        $templater->register('notices', $GLOBALS['notices']);
        $templater->register('notifications_menubits', $GLOBALS['notifications_menubits']);
        $templater->register('notifications_total', $GLOBALS['notifications_total']);
        $templater->register('pmbox', $GLOBALS['pmbox']);
        $templater->register('return_link', $GLOBALS['return_link']);
        $templater->register('template_hook', $GLOBALS['template_hook']);

        $navbar = $templater->render();


ThorstenA 08-19-2010 08:07 PM

Notice: For working with the $show variable array, you need to put the $navbar creation code in showthread.php after the $show variables are set.

Boofo 08-19-2010 09:20 PM

Why don't you just preRegsiter the variable in the hook? No need to replace code in the php file.

Code:

vB_Template::preRegister('navbar', array('thread' => $thread));

ThorstenA 08-20-2010 10:21 PM

Quote:

Originally Posted by Boofo (Post 2086578)
Why don't you just preRegsiter the variable in the hook? No need to replace code in the php file.

Code:

vB_Template::preRegister('navbar', array('thread' => $thread));

Great idea! Thanks for your help!

In this particular case I am happy to have it with the file edit as I have put the navbar template code below the part, where the $show variables are set. But I know, I may create the $show variables in a plugin, too. Just think that the 4.0.x releases are very few, so file edits are okay for me now :)

Boofo 08-20-2010 10:34 PM

File edits are a thing of the past and not necessary anymore. But to each his own.

ThorstenA 08-20-2010 10:40 PM

Quote:

Originally Posted by Boofo (Post 2087131)
File edits are a thing of the past and not necessary anymore. But to each his own.

Despite what I am doing in this case, I couldn't agree with you more :)


All times are GMT. The time now is 11:28 AM.

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.01600 seconds
  • Memory Usage 1,729KB
  • 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
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete