vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   Using Template hook for plugin development vb5 (https://vborg.vbsupport.ru/showthread.php?t=320910)

VineetN 11-27-2015 11:41 AM

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>

Replicant 11-27-2015 07:47 PM

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-

VineetN 11-30-2015 04:34 AM

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.

Replicant 11-30-2015 10:13 AM

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.

VineetN 12-01-2015 07:07 AM

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..:-)

Replicant 12-04-2015 04:37 AM

Quote:

Originally Posted by VineetN (Post 2559535)
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 (Post 2559535)
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

VineetN 12-07-2015 04:40 AM

Ohhk...I have overcome this...Thanx a lot for the help!!


All times are GMT. The time now is 05:54 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.01059 seconds
  • Memory Usage 1,724KB
  • 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_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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