vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Conditional Plugin (https://vborg.vbsupport.ru/showthread.php?t=262466)

SkyStryder 04-22-2011 05:47 PM

Conditional Plugin
 
I am developing some new plugins that should only work with a new
style I am working on. My new template style is "9". I only want the plugin to
fire if it is my beta template. This code does not seem to work even though
when I var_dumped the array, it seemed that styleid was being set.
I put it as the first line of the plugin. I was also hoping to put it in the
Navbar: Insert CMS Navbar Entry plugin, so I could import the CMS to the
live site and then turn it on to the public when ready.

Code:

if ($vbulletin->options['styleid'] != '9')
 {
 return;
 }

Any ideas?
Thank you!
Rick

Lynne 04-22-2011 05:51 PM

What hook location are you using? You should look the hook up in the code and see if $vbulletin is global or not. If not, you need to make it global. Or, it could be the variable name is wrong. So, find the hook and see what the code is like around it.

SkyStryder 04-25-2011 03:39 PM

The Hook location is process_templates_complete
I am using the plugin to create navbar tabs.

Lynne 04-25-2011 04:01 PM

Is the styleid available for use at that point - have you tried spitting it out right there and seeing if it is correct? (And don't you want to use $vbulletin->userinfo['styleid']?)

SkyStryder 04-25-2011 06:09 PM

I am starting to see what is wrong. These are template plugins, not php plugins.
I tried surrounding the Navbar tab plugin stuff with

if (vb::$vbulletin->options[styleid] !== '9') return; Didn't work. I know why
---
if (vb::$vbulletin->options[styleid] == '9') Didn't work, don't know why
{
plugin code
}
---
and last but not least, when I realized this was a template plugin:

<vb:if condition = "$bbuserinfo['userid'] == 1"> Doesn't work, don't know why
plugin code
</vb:if>
Parse error: syntax error, unexpected '<'

On a PHP eval page, this works: $output = vb::$vbulletin->options[styleid];

nhawk 04-25-2011 06:55 PM

Quote:

Originally Posted by rickf (Post 2188497)
The Hook location is process_templates_complete
I am using the plugin to create navbar tabs.

Use the parse_templates hook for anything that needs to be done during a template load.

That is where I modify the navbar so I would think it would work.


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