• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Passing search criteria via URL's

Marcel

Active member
#1
Hi

When on vBulletin, I composed a handful of custom links to the search URL.
They were pretty much so our members had a quick link to a custom search with particular criteria.

For example "All new photo sharing threads", which showed all unread threads in forum x, y and z.
We also had an "Unanswered sharing threads", which showed all threads from x, y and z with 0 replies.

It helps build our community spirit by having these, as members can quickly identify those threads that are needing responses etc

So is it possible to build a custom URL based on search parameters, like this?
Here are a couple of the links we used to use on vB

{removed}/forums/search.php?do=process&replyless=1&replylimit=0&searchdate=7&beforeafter=after&sortby=lastpost&showposts=0&forumchoice[]=5&childforums=1&exclude=67,69

{removed}/forums/search.php?do=process&replyless=1&replylimit=99999&searchdate=30&beforeafter=after&sortby=lastpost&showposts=0&forumchoice[]=8&childforums=1

{removed}/forums/search.php?do=process&searchdate=30&beforeafter=after&sortby=lastpost&showposts=0&prefixchoice[]=critique&forumchoice[]=5&childforums=1


Thanks.
 

Brogan

XenForo moderator
Staff member
#5
A quick check of the search form suggests these are the field names: keywords, title_only, users, date, reply_count, nodes[], child_nodes, order.

I just posted this on another thread as a similar question came up yesterday, but it also applies here so I'll post the same examples:

For example, a hard coded URL to search for threads started by me would be:http://xenforo.com/community/search/search?users=brogan&user_content=thread

For threads started by me in the Suggestions forum it would be: http://xenforo.com/community/search/search?users=brogan&user_content=thread&nodes[]=18
 

Marcel

Active member
#6
Thanks, you two :)

I found the above while browsing last night in bed (Not sure why I didn't find it before).
We can use that to some extent for a couple of our search links.
How do I expand the nodes[] parameter/array to include more forums, and child forums?

Also, the problem we have is that we don't want to search for a specific string of text, or a specific user. We just want to pull all threads with that criteria.
For the other links, we would need other criteria such as

maximum replies, date ranges etc.

From what I can see looking at the search files I think I'm going to need to do this via a plugin arent I?
 

Ludachris

Well-known member
#8
A quick check of the search form suggests these are the field names: keywords, title_only, users, date, reply_count, nodes[], child_nodes, order.

I just posted this on another thread as a similar question came up yesterday, but it also applies here so I'll post the same examples:

For example, a hard coded URL to search for threads started by me would be:http://xenforo.com/community/search/search?users=brogan&user_content=thread

For threads started by me in the Suggestions forum it would be: http://xenforo.com/community/search/search?users=brogan&user_content=thread&nodes[]=18
How would you properly structure those links in the templates? I'm stuck:

Code:
<a href="{xen:link search/member, '', 'user_id={$visitor.user_id}, '', 'user_content=thread'}">Your Threads</a>
 

Brogan

XenForo moderator
Staff member
#9
You can just add it like so:
Code:
<a href="http://mysite/search/search?users=me&user_content=thread&nodes[]=10">Click To Search</a>
 

Marcel

Active member
#13
@JJJ If you just want to pull the threads with that criteria (with no username or no query), then unfortunately not (I'm pretty sure, anyway).
I ended up doing it the harder way and created my own plugin for it.