1

I have a site with news and I want to make it possible for admin to add image gallery to Articles (nodes) the admin wants. So, the idea is to make gallery image field for every content type from which images should be taken. If admin wants gallery for that article the admin can upload images, if the admin don't the admin can just leave it alone, and Drupal renders that node without gallery perfectly normal.

So, I made that gallery image field for every content type, and used Views module for taking and rendering pictures. But, whereas views taking pictures at content type level not node level, that is the reason why unpleasant consequence appear: gallery from particular node, shows on every node of that type.

My question is how to make galleries relative to particular nodes (specific gallery for specific node)? And it should be extremely easy for admin to manipulate.

1
  • 3
    "and used Views module for taking and rendering pictures." - why? Drupal is perfectly capable of displaying multi-value image fields even without use of Views. Just use this capability and you will get your "specific gallery for specific node". Or am I missing something?
    – Mołot
    Commented Jul 22, 2014 at 13:23

3 Answers 3

0

The simplest way: Use colorbox module

In the structure of the content type add an image type (with multiple values allowed) and put its display type to be a colorbox gallery

The complex way: use view slideshow and computed field

Still add an image field to the content type, but set its rendering to hidden.

Add a computed field with the value equal to the node nid and the display a view that take the node nid as contextual filter and render the image field using the slideshow plugin.

Set the display of this computed field as unsanitized.

Computed code:

if (!$entity->nid) node_save($entity);

Display Code (PHP):

$display_output = views_embed_view('<your view name>','<your view display name>',$entity_field_item['value']);

You can get an example here: http://agriregionieuropa.univpm.it/content/event/test-antonello (tab "video ed immagini").

The video slideshow uses the second approach (in this case videos, in your case photoes, it's the same), while the photo gallery uses the colorbox approach.

0

how to make galleries relative to particular nodes (specific gallery for specific node).

You have probably forgot the contextual filter "content nid" in your views:

In the option "When the filter value is not available":

  1. add "content nid" in your view
  2. check the line "Provide default value"
  3. Select "Content ID from URL" from the dropdown

enter image description here

0

You could use that gallery field formatter which gives you the ability to make the image field which have multiple values to be displayed as a gallery enter image description here You could control the field display settings from its display settings per content type

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.