Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2011, 12:23 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 05-30-2011, 12:43 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 05-30-2011, 12:58 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 05-30-2011, 01:06 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Simon Lloyd View Post
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.
Reply With Quote
  #5  
Old 05-30-2011, 02:01 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>";
}
Reply With Quote
  #6  
Old 05-30-2011, 02:09 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Simon Lloyd View Post
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.
Reply With Quote
  #7  
Old 05-30-2011, 02:30 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 05-30-2011, 02:36 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Simon Lloyd View Post
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.
Reply With Quote
  #9  
Old 05-30-2011, 02:50 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #10  
Old 05-30-2011, 03:06 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:58 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.09112 seconds
  • Memory Usage 2,269KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (4)bbcode_html
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete