tags:

views:

41

answers:

1

A client request:

Create a block that will always display the titles of content items that are the result of a site-search for a specific predetermined term, such as "health".

So in that particular case, the block will generate and display a listing of nodes that contain the word "health" within either the title or body.

Ideally, the predetermined term could be configured either within the block configuration or the view, if generated that way.

I've tried to do this in views, but no luck so far. Ideas?

A: 

Unfortunately, at the moment the search filter only works as an exposed filter, not as a static filter; see http://drupal.org/node/333606. Meanwhile, I can think of two workarounds:

1) You can probably achieve what you need with a couple of lines of code in a custom module, implementing hook_views_query_alter. See http://www.nicklewis.org/hook-views-query-alter-how-programatically-alter-views-queries for more info about this hook.

2) There is a module called Views Modify Query (http://drupal.org/project/views_modify_query) which I have never used myself, but is also meant for custom modifications of the views query.

marcvangend

related questions