PDA

View Full Version : Using Template hook for plugin development vb5


VineetN
11-27-2015, 11:41 AM
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
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?

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!!