So I have a View that is a list of all content on my site. I have an exposed form in a block that is "Search Terms". I have a custom template for my view to customize the results page. I have a couple of content types including "Products" and "Locations".

I'd like the Products to be displayed in a grid format with their corresponding product images and the Locations to be displayed in a list with a corresponding map. What would be the best way for me to accomplish this?

  • From the way you have framed the question it sounds like both types of content can appear on the page at once, which makes the question unanswerable. So presumably your exposed form also includes a content type selection? Commented Jun 3, 2013 at 14:57
  • Why does having both content types on a single page make this question unanswerable? This scenario exists in 99% of all Drupal sites as it is the base template of all site searches. Check out drupal.org/search/site/captcha?f[0]=ss_meta_type%3Amodule. Couldn't this page be customized?
    – Ken J
    Commented Jun 3, 2013 at 15:13
  • As I understood it you want both on the same page? You can't normally have a grid and a list in a single result set. Commented Jun 3, 2013 at 15:14
  • Or rather, you can, but it tends to look a mess. Commented Jun 3, 2013 at 15:20
  • OK, I think I see what you are asking for now. Commented Jun 3, 2013 at 15:23

1 Answer 1


Here's a sketch of an answer: in a views template for the result set you will have access to the original results in $view->result. If the view is set up for fields output, and includes all the fields required including content type, you can iterate through it 3 times, each time ignoring entries that have the content type you don't want for that case.

It's quite hard to come up with clean-looking code because of the way that views names the field data, but if you don't mind that, you can use the dpm() function of the Devel module to inspect it then code accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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