vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Plugin not parsing variables (https://vborg.vbsupport.ru/showthread.php?t=264408)

Simon Lloyd 05-30-2011 12:23 AM

Plugin not parsing variables
 
Hi, i've created a plugin with the following code
HTML Code:

$template_hook[postbit_user_popup].='<if condition="in_array($post[usergroupid], array( 1,2,3,4,5,6,7,8,9,10,11,12,13,14))"> <if condition="is_member_of($vbulletin->userinfo, array( 5,6,7))">
<tr><td class="vbmenu_option"><a href="iptest.php?domain=$post[ip]">WhoisIP for $post[username]: $post[ip]</a></td></tr>
</if></if>';

However the $username and $post[ip] stay exactly like that, they're not getting parsed?

I am using postbit_display_complete as the hook location (and i've tried others) so i don't understand why those aren't getting the data, if i code it by hand in the postbit template it works fine?

Any suggestions would be welcome.

kh99 05-30-2011 12:43 AM

A template hook has to be html, it doesn't get processed like a template. (I believe you would see the if tags unprocessed if you viewed the page source). And your vars didn't get processed because you have the string in single quotes.

So you could do this:

Code:

if (in_array($post[usergroupid], array( 1,2,3,4,5,6,7,8,9,10,11,12,13,14)) AND is_member_of($vbulletin->userinfo, array( 5,6,7)))
{
    $template_hook[postbit_user_popup].= "<tr><td class=\"vbmenu_option\"><a href=\"iptest.php?domain=$post[ip]\">WhoisIP for $post[username]: $post[ip]</a></td></tr>";
}


assuming the values of $post are set at that point in the code.

Simon Lloyd 05-30-2011 12:58 AM

Thanks for the code and the info, would the AND be correct? the first IF is which groups the item can be seen/used on the second gives the permission for who can see and use it.

EDIT:
Your code gives:
Parse error: syntax error, unexpected T_STRING in /home/thecodec/public_html/testforum/includes/class_postbit.php(294) : eval()'d code on line 3

kh99 05-30-2011 01:06 AM

Quote:

Originally Posted by Simon Lloyd (Post 2201496)
Thanks for the code and the info, would the AND be correct? the first IF is which groups the item can be seen/used on the second gives the permission for who can see and use it.

You can change it back to the two ifs if you want, it amounts to the same thing if there's nothing else inside the outer if.

Quote:

EDIT:
Your code gives:
Parse error: syntax error, unexpected T_STRING in /home/thecodec/public_html/testforum/includes/class_postbit.php(294) : eval()'d code on line 3
Oops - now I see why you had it in single quotes. I fixed the above code by adding backslashes to escape the double quotes. You could also do $str = 'part 1 ' . $post['userid'] . 'part 2, etc'; if you prefer that.

Simon Lloyd 05-30-2011 02:01 AM

Err, wish i knew what you meant there!, using your amended code the item doesn't display in the postbit userinfo dropdown.

Thanks for your help here :)

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

This works but im sure i've lost control over it somewhere as i should be able to choose which usergroups it will be available for then which ones can actually use it
HTML Code:

if (in_array($post[usergroupid], array( 1,2,3,4,5,6,7,8,9,10,11,12,13,14)))
{
    $template_hook[postbit_user_popup].= "<tr><td class='vbmenu_option'><a href='iptest.php?domain=$post[ip]'>WhoisIP for $post[username]: $post[ip]</a></td></tr>";
}


kh99 05-30-2011 02:09 AM

Quote:

Originally Posted by Simon Lloyd (Post 2201520)
Err, wish i knew what you meant there!,

Just that there's more than one way to address that issue, but it doesn't matter.

Quote:

..using your amended code the item doesn't display in the postbit userinfo dropdown.
It looks like $vbulletin is not defined at that hook location, so try changing it to $this->registry->userinfo in the is_member_of() call.

Simon Lloyd 05-30-2011 02:30 AM

I tried this
HTML Code:

if (in_array($post[usergroupid], array( 1,2,3,4,5,6,7,8,9,10,11,12,13,14)) AND $this->registry->userinfo in the is_member_of(5,6,7)))
{
    $template_hook[postbit_user_popup].= "<tr><td class=\"vbmenu_option\"><a href=\"iptest.php?domain=$post[ip]\">WhoisIP for $post[username]: $post[ip]</a></td></tr>
</if></if>";
}

but it's giving Eval errors, one other thing, do we need the two </if>'s?

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

Lol, it's 4:30am here and i wasn't reading it properly, this works
HTML Code:

if (in_array($post[usergroupid], array( 1,2,3,4,5,6,7,8,9,10,11,12,13,14)) AND is_member_of($this->registry->userinfo, array( 5,6,7)))
{
    $template_hook[postbit_user_popup].= "<tr><td class=\"vbmenu_option\"><a href=\"iptest.php?domain=$post[ip]\">WhoisIP for $post[username]: $post[ip]</a></td></tr>
</if></if>";
}

thanks for your help :)

kh99 05-30-2011 02:36 AM

Quote:

Originally Posted by Simon Lloyd (Post 2201530)
I tried this...

Sorry, i meant like this:

Code:

if (in_array($post[usergroupid], array( 1,2,3,4,5,6,7,8,9,10,11,12,13,14)) AND is_member_of($this->registry->userinfo, array(5,6,7)))
{
    $template_hook[postbit_user_popup].= "<tr><td class=\"vbmenu_option\"><a href=\"iptest.php?domain=$post[ip]\">WhoisIP for $post[username]: $post[ip]</a></td></tr>";
}

Quote:

... one other thing, do we need the two </if>'s?
Oh, good call - I missed those. You're right, you don't need them.

Simon Lloyd 05-30-2011 02:50 AM

Brilliant thanks, i can now complete my very first product, so im going to update my vb3.8.x Add-on https://vborg.vbsupport.ru/showthread.php?t=264283 and make it easier for folk rather than template edits, i'll add that in the next 5 mins or so, fancy giving it a go for me?

kh99 05-30-2011 03:06 AM

I tried it and it works, nice job! However there's a slight problem with the xml file, something to do with the version check url on line 8. I just deleted that from the xml to test it, I'm sure it's something minor.


All times are GMT. The time now is 10:30 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.01226 seconds
  • Memory Usage 1,749KB
  • 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
  • (2)bbcode_code_printable
  • (4)bbcode_html_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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