XF 1.5 Create a link that points to a search with this criteria?

Ludachris

Well-known member
I'm looking to create a text link that points to a search result with the following criteria:

  • specified node IDs
  • no keyword
  • display threads sorted by highest views
I have several "article" style sub-forums and I will be posting a link in the description of the category pointing to the "most viewed" articles across all sub-forums in that category. I figure the link will be structured like this, but don't know how to handle the sorting:

search?&user_content=thread&nodes[]=XX
 
Last edited:

Mike

XenForo developer
Staff member
First, the search doesn't support sorting by thread views, so that would scupper using the search for that. Beyond that though, I don't think the search would actually allow you to complete the search in this context without a keyword.

Thus this would require custom development.
 

Ludachris

Well-known member
First, the search doesn't support sorting by thread views, so that would scupper using the search for that. Beyond that though, I don't think the search would actually allow you to complete the search in this context without a keyword.

Thus this would require custom development.
Well, assuming I've already done custom development so that the search does function without a keyword, it sounds like I wouldn't be able to force the sorting by a formatted text link. Well that sucks. I suppose I could create a widget page since I'm using 1.5 still, but I'm not sure how that would translate to 2.x, and I'm trying hard not to implement anything I can't migrate to 2.1.
 

Mike

XenForo developer
Staff member
You can make a link that goes to a particular search -- just that out of the box, there is no search criteria that does what you want. Even with a modification to skip keyword restrictions, you still can't sort the threads by views as that's not exposed.

I believe the closest you can get in 1.5 is something like this (untested): <url>/search/search?type=thread&nodes[]=1&nodes[]=2&nodes[]=3&order=date
 

Ludachris

Well-known member
You can make a link that goes to a particular search -- just that out of the box, there is no search criteria that does what you want. Even with a modification to skip keyword restrictions, you still can't sort the threads by views as that's not exposed.

I believe the closest you can get in 1.5 is something like this (untested): <url>/search/search?type=thread&nodes[]=1&nodes[]=2&nodes[]=3&order=date
Thanks Mike. What is the closest I can get in 2.1?
 

Ludachris

Well-known member
So the only thing that prevents me from doing what I need is really the inability to use "&order=views". Thanks again Mike.
 

Mike

XenForo developer
Staff member
This won't work out of the box because of the keyword/user limit, but the equivalent would be <url>/search/search?search_type=post&c[content]=thread&c[nodes][]=1&c[nodes][]=2&order=date
 

Ludachris

Well-known member
This won't work out of the box because of the keyword/user limit, but the equivalent would be <url>/search/search?search_type=post&c[content]=thread&c[nodes][]=1&c[nodes][]=2&order=date
Hey @Mike - I used to use this trick in XF1.5 to remove the keyword/user constraint for search:

How would that be achieved in 2.1? I dug through the files but couldn't find similar code.
 
Top