![]() |
Related topics for non-vB pages
This isn't really a hack, more of an add-on for vBulletin.
What I'm trying to do is create a method of displaying related topics at the end of articles for NissanPerformanceMag.com. This isn't the same as the "Last XX Posts on non-vB page" hack. Instead, it uses some specified keywords to display 10 discussion topics related to the subject of the article. I haven't been able to locate any similar projects, so I attempted it myself. :) It's easy to get lost in the search.php file (at least for me :)), but I was able to figure out enough to get this far. It displays the queries used, as well as the final results. The problem is it doesn't work very well with multiple words, such as this: I can't figure out how to make it display threads containing all of the search words. Right now it uses "OR" instead of "AND", if you can see what I mean. It also doesn't give any weight to results. If anyone can offer some insight into methods of improving this I would appreciate it very much! :) What I would like to do (using the second link as an example), is display threads containing all the search words instead of simply displaying threads that contain just one. Here's the code: PHP Code:
|
Well, I did eventually figure out the problem. It just involved rewriting a couple of the queries. I removed the link from the previous post because I've since deleted the file.
|
This sounds like what I'd like to implement. Can you share with us the final hack?
Thanks Steve |
Sure. Here's what I came up with. The only real differences between my first attempt and this final version are the third and fourth MySQL queries. It does not return the most recent results. What it does instead is group the threads with the highest number of instances of the search word(s), and then sort those by date. It may not be the most efficient or desirable system for your particular application, but it seems to work pretty well. ;) If you come up with any improvements please let me know.
I've simply included it as a function, which can be called with some keywords separated by spaces. I'd recommend not using more than 2 or 3 keywords simply because of the large number of posts it will find. If you print out the queries like I did in my first example you'll see just how many! Change "LIMIT 5" to the number of results you want. PHP Code:
PHP Code:
Scott |
Hey nice mag, how can I subscribe :O)
-Arunan |
It's online only at this time. :) Eventually we want to have it in print, but we're not there yet.
|
How are you calling the function from the search form? I can't seem to get it right, can I have a copy of your search form?
|
A search form is not required. Call the function from within your PHP file with some words and it outputs the appropriate HTML. This isn't intended to be used as a search program, but rather a method of displaying related forum topics at the end of articles for NissanPerformanceMag.com. The example I gave above is exactly how it's used for my own situation. I just change the search words as appropriate.
|
All times are GMT. The time now is 12:35 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|