1. 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

Discussion in 'XenForo Questions and Support' started by Marcel, Nov 9, 2013.

  1. Marcel

    Marcel Active Member


    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




    island likes this.
  2. ehd

    ehd Active Member

    Yes, I am also VERY intererested if there is something like this.
  3. Marcel

    Marcel Active Member

  4. Mike

    Mike XenForo Developer Staff Member

  5. Brogan

    Brogan XenForo Moderator Staff Member

    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
  6. Marcel

    Marcel Active Member

    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?
  7. Brogan

    Brogan XenForo Moderator Staff Member

    You can use any of the field names and values available from the template.
  8. Ludachris

    Ludachris Well-Known Member

    How would you properly structure those links in the templates? I'm stuck:

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

    Brogan XenForo Moderator Staff Member

    You can just add it like so:
    <a href="http://mysite/search/search?users=me&user_content=thread&nodes[]=10">Click To Search</a>
  10. Ludachris

    Ludachris Well-Known Member

    I tried that and I get an error saying it can't find user me. So do I use a variable like $username for me?
  11. Ludachris

    Ludachris Well-Known Member

    Got it, I replaced it with {$visitor.username}.
  12. JJJ

    JJJ Active Member

  13. Marcel

    Marcel Active Member

    @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.

Share This Page