0

I have two content types (Movies and Actors), both with picture and name fields.

In Movies I have a field collection with two fields: name and character. This name field is a node reference to Actors content type. I created a view block for the Movies nodes which lists the cast (a list of Actors nodes).

What I want is the actor's pictures. The picture is automatically added to the Movies nodes; I would want the same for my block.

enter image description here

enter image description here

enter image description here

enter image description here

3
  • 1
    It's not that easy as you are using field collections. A field collection is an entity by itself already. So if viewing a movie node, you would need to get all related field collection items. Then, you would need all the actor ids from these items and use them to produce a list of actor nodes. Also afaik, it is currently not possible to have multiple relations in a single view coming from one field (with multiple values). So, you should probably think of another way to build the structure or you need to come up with a custom script (module) to do the work.
    – Paul
    Jul 17, 2014 at 12:51
  • @Paul thanks for your answer, i try to find a way but still i cant.. any idea how can i do that?
    – sharktale
    Aug 8, 2014 at 12:45
  • Did you try adding a relationship in your view? You should be to list the name of the character and it's photo from the releationship. Aug 10, 2014 at 14:23

1 Answer 1

0

(1) The only way of not writing a custom script I can think of would be to use the Display Suite module. Out of the blue I would try the following.

  • Create a new display mode (besides content and teaser) for the actor content type. Call it something like "just image" or "photo only". It should be set to only display the image field.
  • Create a new display mode for the movie content type, maybe called "actors". It should only display the field collection and the name (reference field) should use the previously created display mode "just image".
  • Create a (views) block that shows the original node (Contextual Filter: Nid, default parameter in URL). Display type of that view should be Node and use the "actors" display mode.

What I would expect is to get a block that shows the actors' photos along with their characters' names.

(2) An easier way (if you are able to program Drupal modules) would be to write custom scripts. Also, this would allow you to fine-tune your output. I would create a custom module which creates the block you want by using the _block hooks to define the available blocks and their contents.

(3) Another way of accomplishing what you want would be to restructure your website's architecture. This might not be suitable for you if you already have a lot of entries. Instead of field collections you would then use an additional content type (character). Character would then have relationships with both movies and actors.

4
  • hi again.. i try to (1) but i stuck with the secend step.. "and the name (reference field) should use the previously created display mode "just image". what does it mean? how can i do that, i think i understrand wrong this section..
    – sharktale
    Aug 14, 2014 at 9:35
  • For more info step by step what i done ==> 1)I go to actor content type and manage display. And create a new display mode call "just image".It is only own image field. 2) I go to movie content type and create a display mode call "actors". It is own just a field collection field(has 2 field; actor name (node referance) and character name). I think I miss something in this step.. I dont understand the sentence i wrote in previous comment.. 3)I create a view block.. I select "show: content".. then in format section i select "display suite" and from its settings select actors as default view mode
    – sharktale
    Aug 14, 2014 at 11:58
  • The node reference field (actor name) should have settings (like for images you can choose the image style you should here be able to choose the reference type, it should provide something like "Label only", "Rendered entity", ...). In the settings choose the option to display the rendered entity. Then a new drop-down should appear where you can choose which display mode shall be used to render the entity. Here choose the new actor/just image mode.
    – Paul
    Aug 14, 2014 at 14:57
  • I finally did it :) thank you very much Paul.. for a while it was a big headache for me..
    – sharktale
    Aug 14, 2014 at 15:28

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.