vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Adding quick moderation to header template (https://vborg.vbsupport.ru/showthread.php?t=264467)

Pitman 05-30-2011 10:04 PM

Adding quick moderation to header template
 
I'm trying to add everything back to a few of my sites since I've upgraded everything to vBulletin 4+...

I had all of my moderation links display in the header template if I had anything that needed to be moderated.

Basically, the idea is pretty much: Moderation link replaces logo if there are items to be moderated.

I'm currently using the following code in the global_start hook:

Code:

$modlinks = $db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "adv_links WHERE valid = 0");

vB_Template::preRegister('header',array('modlinks' => $modlinks));

This plugin doesn't seem to push the $modlinks variable through to the header template. I'm using this code in the header template:
Code:

<vb:if condition="$modlinks">Test</vb:if>
It doesn't work though, and I definitely have links that are in need of being moderated.

I have also tried the parse_templates hook, which works for some things, however, when using that hook instead of global_start... I get a blank page. :(

Any help would be appreciated! :)

kh99 05-30-2011 10:43 PM

When I try this plugin code:

Code:

$modlinks = array("foo");
vB_Template::preRegister('header',array('modlinks' => $modlinks));

And your template code in the header template, I see "Test" appear in my header. So that would seem to indicate that the query is failing. I don't have any adv_links table in my database, so maybe that's changed? (Although I don't have it in my vb3.8.3 database either).

Pitman 05-31-2011 08:49 PM

adv_links is an addon vBadvanced Links Directory.

I'm trying to do the same thing with everything else... you could also try with this:

Code:

$modthreads = $db->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "thread WHERE visible = 0");
The query should work as it works in other places, but for some reason it's not.

Thanks for your help! :)

kh99 05-31-2011 11:28 PM

Hmm...I may be wrong. I'm not sure if there is any condition where $db->query_first returns something that would cause the conditional to be false. I put a different query in there like you suggested and it worked.

So could you problem be that something else is changing the value of $modthreads before you get to the header template render()?

Pitman 06-01-2011 02:11 AM

Hmm... well, I'm glad you said that, however there isn't anything else changing the value of it. It seems to have been the execution order for some reason. Anything 5+ doesn't work, less than 5, it works just fine.

Thank you! :D

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

Err... looks like I actually spoke too soon. When changing to execution order to 4 or below, all of the variables have a value of "Array" instead of the actual number. :(


All times are GMT. The time now is 07:03 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.01016 seconds
  • Memory Usage 1,717KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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