By Charlie Sibbach on
I have a client that wants to show "sponsored" content in a block on top of the ordinary search results. Sponsored is a CCK field in all of my node types. I'd like to figure out the easiest way to do this. Basically, I need to create a search query based off the base search query (block will show up on search/*, so I can use arg(3) to get that, I think), with a sponsored content only caveat in it.
I was hoping I could do it with a view, but there's no argument or filter that will do the trick. What is the best way to do this?
Comments
So, I looked and asked
So, I looked and asked around, and turns out that there IS a filter for search terms available. I'd like to embed this view into the search page without exposing the filter (it should just match the dominant search terms). How can I dynamically update the filter to do this?
I just spent the last 3
I just spent the last 3 hours trying to make a view with a "search term" filter work WITHOUT exposing the search term. Here's what I came up with:
Here's the trick. The search handler class has a bug in it- reading through it, the only way it gets the search_query variable is through exposed_validate! My code above works fine- if by fine I want to insert the query into the Options array, rather than in the core of the handler class! The views_handler_filter_search class does not handle options correctly, it's set up to ONLY be used while exposed!
Great work!
Thanks. I am not very clear where should I put the codes above to?
Here's a patch for anybody
Here's a patch for anybody interested, so that you can use a non-exposed Search Terms filter:
In views/modules/search/views_handler_filter_search.inc, change:
To:
To use it, use the code I have listed above when creating your view. Its no good for just standard views as is, you need to build the view by hand as above.
I'm trying to create a block
I'm trying to create a block to display on all nodes of a certain content type that will take the title of the node, treat it as a search and display search results (in the form of a views-created block) accordingly. Would I use a similar methodology as what you've used above?
Looking to do this too. Still
Looking to do this too. Still haven't found a solution... other than SOLR - Views 3 kinda things.