1

I have created a views page which list maximum of 50 nodes of type 'event'. It works fine but I want have a single image banner on the top that can be uploaded by the logged in user from the admin area for that page. I can't add a banner field on the event content type as it will get pulled 50 times.

The other solution I managed was to create another content type called 'Banner image' and create another view which lists 1 node of event type 'Banner image' and add it to the initial page view but that seems like a really dirty solution. Is there a simpler solution to this problem?

2 Answers 2

1
  1. Create a admin form that allows the admin user to upload the image file, as you say in your question.

  2. Create custom block that renders the image as you want. You can do in a custom module (better, more solid) or crete the block using the GUI and add the HTML code. In both cases, the img should point the file uploaded by the admin form.

  3. Place the block over your view in the view's page.

This is good if:

  • You only have one view that needs the header image.

  • That image is the same for evey user.

1

The other solution I managed was to create another content type called 'Banner image' and create another view which lists 1 node of event type 'Banner image' and add it to the initial page view but that seems like a really dirty solution.

If you want your users to be able to change the image easily, and you want to always show the last image (for example), this is a solution.

Another solution is adding the view as a block to the content type image. Or vice versa (which is @sanzante's answer)

You can look into Entity Views Attachment module, https://www.drupal.org/project/eva.

You can modify the view template files and add the image there.

There are many ways. It depends ultimately on flexibility and what you need.

Your Answer

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

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