3

I'm trying to show different sets of four images in sidebar depending on which page a visitor is viewing. Aside some trouble I'm wondering whether a proper workflow should be as follows:

  1. Create "Four Images" content type set up as a single multiupload image field.
  2. Create "These Four Images", "Those Four Images", etc. content.
  3. Create as many views as content units in step two set up as a grid block.
  4. Add every block to sidebar in Block Design and restrict each block to be displayed using "Visibility->Pages".

So I'm getting a Sidebar in Block Design rapidly filled with four images views. Is there any other cleaner way of doing this?

1
  • It is not enough info about what you need, but i think you can create some content type "Four Images", create block in Views and set some context filter that will define what four images to show depending on page context.
    – Andrew Nim
    Commented Feb 6, 2017 at 10:31

1 Answer 1

1

Create as many views as content units.

Is there any other cleaner way of doing this?

Yes, you do not need to create a View for each of your nodes/pages/content. You can create a dynamic view which automatically passes the Content ID to Views.

  1. Create "Four Images" content type set up as a single multiupload image field.
  2. Add these "Four Images" to you node.
  3. Create a View Block

enter image description here

  1. In View, for Fields, add your image

  2. Click on Advanced (far right), for Contextual Filter add ID .Provide default value, Content ID from URL. (Note: The view preview will go blank, which is normal, since the View edit page does not have a Content ID.)

enter image description here

  1. Go to blocks (/admin/structure/block), and add the View block to a region. For Visibility settings select the content type that you want this to appear in.

enter image description here

1
  • 1
    Nice. Works flawlessly!
    – Antonio
    Commented Feb 6, 2017 at 13:21

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.