Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-27-2015, 11:41 AM
VineetN VineetN is offline
 
Join Date: Nov 2015
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using Template hook for plugin development vb5

Hello,

I am trying to develop a plugin compatible with vBulletin5. Since vb5 allows template hooks, I am not able to use php script. Can someone tell me as to how should I execute a SQL query. And also I am trying to do the following to store the value of current loggedin user's usergroupid in 'groupid'. But I am not able to retrieve the value in it. Please provide your assistance.

Code Snippet:
<vb:if condition="!empty($vboptions['testing'])">
{vb:set groupid, {vb:raw bbuserinfo.usergroupid}}
{vb:raw groupid}
</vb:if>
Reply With Quote
  #2  
Old 11-27-2015, 07:47 PM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can use php. It just needs to be in a vb5 product and you call it with a vb:data call in the templates. You can then display info from the data array using vb:raw. Depending on simplicity of the plugin, a php module may be in order without the need for custom templates.

Here is a tutorial on developing a simple vb5 product
http://www.vbulletin.com/forum/blogs/joe-d/3932614-
Reply With Quote
  #3  
Old 11-30-2015, 04:34 AM
VineetN VineetN is offline
 
Join Date: Nov 2015
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And is there any way where i can run sql queries within the template hook.
and Thank You for the reply..will try this as per the tutorials.
Reply With Quote
  #4  
Old 11-30-2015, 10:13 AM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes there is. You have to write an extension api, then call that api from the template using {vb:data} in the template. It's fairly involved but once you understand the process, it gets really simple. I'm in the process of getting all this info together in one place but work has kicked up and I don't have much time. Maybe in a week or two, I'll get the info posted. If you're trying to do something fairly simple and specific, shoot me a PM and I'll look at writing an example code for you this evening.
Reply With Quote
  #5  
Old 12-01-2015, 07:07 AM
VineetN VineetN is offline
 
Join Date: Nov 2015
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I was just trying to get the membergroup ids from the db of a logged in user. It would be a great help if I get a example code snippet to fire a sql query within the template hook.
Thanks for the reply..:-)
Reply With Quote
  #6  
Old 12-04-2015, 04:37 AM
Replicant's Avatar
Replicant Replicant is offline
 
Join Date: Sep 2014
Location: Phoenix, Az. USA
Posts: 485
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by VineetN View Post
I was just trying to get the membergroup ids from the db of a logged in user.
Are you looking for primary and secondary usergroups or just the primary?

Quote:
Originally Posted by VineetN View Post
It would be a great help if I get a example code snippet to fire a sql query within the template hook.
Thanks for the reply..:-)
You can't just fire an sql query within a template hook. You can call vB api or your own custom api using the vb:data call in the template.

Here is an example of how to use it. This is used to get profile data for a user

{vb:data postInfo, user, fetchProfileInfo, 6}

postInfo is the variable the data is returned to. user is the api. fetchProfileInfo is the method being called. 6 is the userid. once this is called, you can display the data by using vb:raw.

{vb:raw postInfo.usergroupid} would display the usergroup id of userid 6
Reply With Quote
  #7  
Old 12-07-2015, 04:40 AM
VineetN VineetN is offline
 
Join Date: Nov 2015
Posts: 14
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ohhk...I have overcome this...Thanx a lot for the help!!
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 07:43 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09103 seconds
  • Memory Usage 2,213KB
  • 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_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete