Sign Up for OSTraining

Welcome, Guest
Username: Password: Remember me

TOPIC: filter in view to display actors for a movie

filter in view to display actors for a movie 11 months 3 weeks ago #47684

in the intermediate course actors are related to movies through a multivalued field "movies" in the key person content type.

To define a view listing the actors for a movie, it would be necessary to have a filter which specifies that the content:movies field "contains" the movie id.

How can this filter be created, or what other method can one use to select only the actors relating to the movie?
Please become a member of OSTraining to reply to this post.

filter in view to display actors for a movie 11 months 3 weeks ago #47714

  • rod.m
  • rod.m's Avatar
  • OFFLINE
  • Administrator
  • Posts: 391
  • Thank you received: 28
  • Karma: 5
Hi Clive,
I'm assuming you're wanting to do some kind of view that you could insert using Panels or Display Suite - or just a block for that matter. Let's do a contextual block that grabs the images from the actor content type and places them on the movie page:

Go to Structure ->Views -> Create a View
Give it a title
Change Content type to People
Deselect Page
Select Block
Display: HTML List of titles(linked)
Change # to 30 (or whatever)
Click Continue and Edit

Click on Advanced

Next to Relationships - click Add
Select Content:Actors (or whatever you named your Node Reference field)
The machine name should populate into the Identifier field.
Check the box - Require this relationship
Set the Delta to all
Click Apply

Next to Contextual Filters:
Click Add
Select Content:Nid - this gets the node id of the movie
Click in Provide Default Value and select Content ID from URL
Click Apply

In Fields - remove all
Add: Content: Title - but choose the relationship you created
Add: Content: Photo - and choose the relationship you created

In Filter Criteria - remove all except published(Yes)
Add: Content: Type (People) and apply the relationship as above.

Add whatever sort criteria you want

in the Preview below - you'll need to put the node id of a movie to see the actors.
to get the node id if you're using human friendly URL's - go to the "find content" page, hover over the edit link to a movie - the node id will be in the URL.

This is a pretty complex view - and far beyond the scope of our beginner or intermediate course... but I hope this helps

Once you've finished the view - place it in a region and configure the block to only show up for the movie content type.

Rod


follow us on Twitter twitter.com/ostraining
Facebook - facebook.com/ostraining
Please become a member of OSTraining to reply to this post.

filter in view to display actors for a movie 11 months 3 weeks ago #47735

Hi Rod,

Thanks very much for your detailed and most informative reply. I can see how this should work, and have implemented it (almost) exactly as specified. I do have a problem however - when attempting to assert the contextual filter (which is obviously essential) I get an error from the views interface :

"An illegal choice has been detected. Please contact the site administrator."

I have tried every permutation of input fields I can think of, but cannot seem to get the apply to work no matter what. Every possible selection (including all default) provides the same error.

Of course, the view does not work, which is not surprising.

Any ideas?
Please become a member of OSTraining to reply to this post.

filter in view to display actors for a movie 11 months 3 weeks ago #47756

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
Hello Clive,

Can you explain what you mean by
when attempting to assert the contextual filter

This message is sometimes generated when trying to submit a form. But I'm not sure from your description what you are doing to get the error.

Can you be more specific?

Thanks
Ed
Please become a member of OSTraining to reply to this post.

filter in view to display actors for a movie 11 months 3 weeks ago #47763

Hi Ed,
You are right - it is when trying to submit the form specifying the contextual filter. When I click on the "apply" button at the bottom of the form, the error pops up in red at the top and the form does not close.

I have tried every possible permutation of parameters, from the top of the form right through - it does not accept any combination of parameters, every single one results in the same error. Also, it does not remove a contextual filter if I click on "remove" - it closes the form, but the filter (half-formed) remains, even if I request remove several times.

It does sound like a bug somewhere, just don't know where or if I am stimulating the bug through one or other parameter somewhere.

I have checked the versions of all modules, and everything on the drupal installation is completely up to date.
Please become a member of OSTraining to reply to this post.

filter in view to display actors for a movie 11 months 3 weeks ago #47766

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
Hi Clive,

The form is trying to access something in the data base or a field that doesn't exist. Sometimes it's because a checkbox or radio button somewhere in your set up is empty. Or the field wasn't defined in Views.

I haven't seen it reported as a problem in this specific case. I'll do some checking and see if I can point you in the right direction.

Ed
Please become a member of OSTraining to reply to this post.

filter in view to display actors for a movie 11 months 3 weeks ago #47769

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0

Is this a form you built or part of the Drupal install? If it's part of drupal there's a bug and you might need to report it to get an answer for it.

Seems you're not the only one having this problem. There aren't any definitive answers I can find, but these are some recent discussions I found that deal with it. Mostly it has to do with form validation and values submitted by the form in question.

drupal.org/node/1499586
groups.drupal.org/node/169519
www.szilagyi-andras.com/info/illegal-cho...t-site-administrator

If you paste the error message into a google search, you find lots of references to it. I'm not sure which would apply in your case. We'll help you if we know or can find an answer, but troubleshooting this may be beyond the scope of what we can do. Here's a description of what we can do - www.ostraining.com/support-faq/


Ed
Please become a member of OSTraining to reply to this post.

Sign Up for OSTraining

Powered by Kunena Forum

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.