vBulletin Modifications

[How-To] Use plugins to join default queries

Welcome to vBHackers.com! - vBHackers Updates:

Go Back   vBulletin Modifications > General vBulletin Section > General vBulletin Support > vBulletin Modification Tutorials

Reply
 
LinkBack Thread Tools
Old 04-04-2006, 03:41 PM   #1
Ken Iovino
Founder
Ken Iovino's Avatar
Join Date: Mar 2004
Real Name: Ken Iovino
Location: Miami, Florida
Ken Iovino is on a distinguished road

Default [How-To] Use plugins to join default queries

Tutorial Explanation
This tutorial will teach you how to use the plugin system to change default vBulletin queries, without touching the core code.

This tutorial is aimed at users who have an understanding of how the vBulletin plugin system works. Lets get started...

Lets pretend you have a table called.
pretenddata (with 2 fields)
---threadid
---data.

Use this to create the table and values:
You must first be a registered member to view any code.


Now we have some info stored in that table, we want to show it next to the thread title.
From 123.gif to 1234.gif. To do this you would have to hack the $threads query in forumdisplay.php around line 841.

Here is the $threads query

You must first be a registered member to view any code.
The red code is what you would have to add in order to include the table pretenddata with this query.

Lets take a look at what I just did...

LEFT JOIN " . TABLE_PREFIX . "pretenddata AS pretenddata ON(pretenddata.threadis = thread.threadid)

Join the table named pretenddata and rename is AS pretenddata. Now search all threadid fields in the pretenddata table and see if they match the threadid stored in the thread table.
, pretenddata.data AS titleprefix
If they do get contant stored from the fieldname data and rename is AS titeprefix.

Using this method you will beable to show what ever data is in the data table by using this variable in the template threadbit: $thread['prefix']

When you vist threadid #1 it should look like this:
1234.gif

Now that you understand how it works when you hack the files, lets make it a plugin.

Right before that query you should see:
You must first be a registered member to view any code.
And in the query you will see
$hook_query_fields, $hook_query_joins, and $hook_query_where. All you have to do is give those variables some info.

Plugin Manager -> [Add New Plugin] ->
-> Hook Location = "forumdisplay_query"
-> Title = "Testing"
-> Plugin PHP Code =

You must first be a registered member to view any code.
Now you have hacked that query without hacking the core code. ;)

__________________
Earnersforum.com - Learn how to make money online! New Look!

Ken Iovino / vBHackers.com
vBSEO 3.1 GOLD Released vB Blogs Compatible | Non-Encrypted | Branding Removal Option | Sitemaps 2.1 | Language Packs

Crawlability Network: vBulletin SEO | vBulletin Hackers




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 04-04-2006, 03:49 PM   #2
vBulletin Guru
Arnoud's Avatar
Join Date: Nov 2004
Real Name: Arnoud Kuipers
Location: Europe, Flanders
Arnoud is on a distinguished road

Default

Very impressive! I previously thought hacking existing queries was impossible with plugins.

You really are a vB genious :p.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-04-2006, 06:01 PM   #3
Michael Biddle
Administrator
Michael Biddle's Avatar
Join Date: Feb 2005
Real Name: Michael Biddle
Location: Anaheim
Michael Biddle is on a distinguished road

Default

Great job bro, should be useful




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[How To] Run a Query Ken Iovino vBulletin Modification Tutorials 6 08-29-2007 02:23 PM
[How To] Add Options per forum Ken Iovino vBulletin Modification Tutorials 10 03-03-2007 03:25 PM
about SQL highhai General vBulletin Support 1 09-28-2005 08:15 AM


All times are GMT -3. The time now is 03:49 PM.


SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc. (Patent Pending)