PDA

View Full Version : Custom search parameters to create "What's New" for specific sub forums


Samhayne-STS
08-23-2011, 06:41 PM
Hello vBulletin users :)

Our forum is located at http://www.spacetimestudios.com/forum.php As you may notice, we have 3 main areas to our forums: Pocket Legends, Star Legends and Spacetime Studios

Many of our users rely on the "What's New" button to find active discussion. We often receive requests to have a "What's New" search that's specific to each different area. I'd like to change the "What's New" button to be a drop down where you can choose to see what's new on all forums or specific to sub forum.

I see that the What's New button passes in parameters via the URL: http://www.spacetimestudios.com/search.php?do=getnew&contenttyp=vBForum_Post

Does anyone know if it is possible to pass in parameters to create a search of new posts specific by sub forum, namely for each different area: Pocket Legends, Star Legends and Spacetime Studios.

Thank you in advance for your input!

SECTalk.com
08-23-2011, 06:49 PM
I would like the same information. What other parameters can we use? What about thread prefixes or tags?

Thanksk

kh99
08-23-2011, 07:27 PM
You can add '&include=1,2,3' to list the forums you want to include in the output. It looks like you need to list each sub forum as well.

Based on a quick look at the code (and not trying these at all), it looks like the possible parameters (when do=getnew) are: 'days', 'exclude', 'include', 'showposts', 'oldmethod', 'sortby', and 'noannounce'.

I know 'include' and 'exclude' are a comma separated list of forum ids.

The possible values for 'sortby' are: 'title', 'views', 'replycount', 'postusername', 'forum', and 'threadstart'.

I assume 'days' is the number of says to include, and 'showposts' is a boolean that shows posts instead of threads. I don't know what the other ones are.

Samhayne-STS
08-23-2011, 07:29 PM
Awesome, thanks for digging into the code for me! I'll play with it and see what I can put together to make the searches I'm looking for.

kh99
08-23-2011, 07:40 PM
I was thinking, there's a hook location search_before_process, you could probably write a plugin that would let you create your own parameters, for instance if $_REQUEST['section']== 'pocket_legends' then set $_REQUEST['include'] to a list of forums. You might even be able to automatically generate the list of child forums.

Samhayne-STS
08-23-2011, 08:22 PM
Hmm, I see what you're saying, but I'm a community guy by trade. I only play a forum hacker on TV ;)

--------------- Added 1314135049 at 1314135049 ---------------

Yup, so this works for our Pocket Legends section:


http://www.spacetimestudios.com/search.php?do=getnew&contenttyp=vBForum_Post&include=4,5,6,8,9,10,11,12,13,14,15,16,20,23,25,26 ,32,35,36


I just put in the numbers of each sub forum. Kind of a pain if you want to add or delete sub forums.

SECTalk.com
08-24-2011, 06:09 PM
So any possibility of narrowing a search by prefix? It is included on the search form I just don't know what variable to use in the URL.

It was possible in 3.8.

kh99
08-24-2011, 07:04 PM
When you're doing a search with do=getnew or do=getdaily, it doesn't use the tag parameter. You could change that by editing search.php.

Find this (around line 481):

//set critieria and sort
set_newitem_forums($criteria);
set_newitem_date($criteria, $current_user, $_REQUEST['do']);
set_getnew_sort($criteria, $vbulletin->GPC['sortby']);

//check for any errors
$errors = $criteria->get_errors();



and add some code like this:
//set critieria and sort
set_newitem_forums($criteria);
set_newitem_date($criteria, $current_user, $_REQUEST['do']);
set_getnew_sort($criteria, $vbulletin->GPC['sortby']);

if ($vbulletin->options['threadtagging'] && $vbulletin->GPC['tag'])
$criteria->add_tag_filter(htmlspecialchars($vbulletin->GPC['tag']));

//check for any errors
$errors = $criteria->get_errors();


There may be a way to do the same thing just by building a url with the right parameters (instead of using do=getnew and editing the code), but I'm not sure.

SECTalk.com
08-24-2011, 07:05 PM
In 3.8, there was a do= parameter that you could use to process searches and it was simply do=process. I've tried that in conjunction with prefix, prefixid even using brackets after both and nothing has worked thus far.

I'll play with that code. If anyone has a simpler solution, please let us know.

kh99
08-24-2011, 07:17 PM
Oh...doh! For some reason I read 'prefix' and thought 'tag'. I'll look again and see if there's anything for prefix.

--------------- Added 1314218439 at 1314218439 ---------------

OK, if you're using do=process then I think you want prefixchoice[], as in:

search.php?do=process&prefixchoice[]=foo&prfixchoice[]=bar......

SECTalk.com
08-24-2011, 09:06 PM
I tried just that and it did not work.

http://www.sectalk.com/boards/search.php?do=process&prefixchoice[]=Bookie

Also tried = 2, which is the id of the prefix.

--------------- Added 1314223840 at 1314223840 ---------------

Ah ha. The winning combination is:

search.php?do=process&contenttype=vBForum_Post&prefixchoice[]=1

Perfect. Thanks for your help!!!!

kh99
08-24-2011, 09:12 PM
Great - yeah, I should have mentioned that you needed parameters other than the ones I showed.

But I'm a little surprised that worked because when you view the source of the search page the options for the tag selection box is have value="Bookie" (for example) and not value="1".

SECTalk.com
08-28-2011, 02:23 PM
Ah, yeah, it is odd. I wonder if it has anything to do with vBSEO rewriting all the URLs or something.

Maybe not, but I am not too sure on these things.

Thanks again for your guidance!

dougdirac
12-08-2014, 06:39 AM
Is it possible to exclude a particular forum and all it's subforums without listing each subforum ID?