I am working on a script to search groups within the site according to criterias, such as group city, group languages and so on.

So far i am trying to do this by manually querying the database though it s seems to be an unnecessary hassle since the fields i am searching all live in different table like field_data_field_city, field_data_field_language and it can get very tedious task.

So i am wondering if i could to that programmaticaly using views so that it returns me all the NID according to the filters i mentioned above. i'd rather not use views UI as later this data is populated to the page via a Jquery templating system witch is already in place so the best would be to just get all the NID that match my selection.

If anyone had any incite / experience on how i should go to achieve this result would be much appreciated .


Personally I would stick to writing your query manually instead of using Views.

This way you have much more control over the final query, and in most scenarios you should be able to make it much smaller (and thus much faster) than that created by Views - by joining only with tables you really need to join in a specific situation, while Views will always do all the joins required by all possible scenarios.

Also, this way you could return the result formatted whichever way you want, without the need of installing additional modules, which is just unnecessary overhead.

IMHO. :)

  • Thanks for your input, i finaly just created a new table for my group that will index all the data i need for my search script, it s tedious to keep it well updated but ends up with a much faster script. – silkAdmin Sep 12 '11 at 16:08

I think I would just create a view the normal way, using contextual filters (arguments) to filter the results, and use Views Datasource to make the view output json.

  • Thanks for that link marc, i am sure it'll come in handy at somt point though for now i am going to stick with the manual queries for the reasons mentioned by Maciej Zgadzaj. Thanks again for the help ! – silkAdmin Sep 12 '11 at 16:06
  • No problem, I'm glad you found the best tool for the job! – marcvangend Sep 12 '11 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.