0

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? – Alfred Armstrong Jun 3 '13 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 Jun 3 '13 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. – Alfred Armstrong Jun 3 '13 at 15:14
  • Or rather, you can, but it tends to look a mess. – Alfred Armstrong Jun 3 '13 at 15:20
  • OK, I think I see what you are asking for now. – Alfred Armstrong Jun 3 '13 at 15:23
0

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.

| improve this answer | |

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.