Hello,
Im trying to setup a view to style my galleries. I made a view with an entity display which is correctly configured. When I type a node id in the auto preview box it works.
but when I click on my homepage on a gallerynode, no pictures are shown.
So i'm guessing that my ID does not come through.
Any idea's on this?
Comments
Comment #1
simon georges commentedDid you clear your cache (especially your Views cache)? If it's working in the preview, it should be working on the content (unless you hide EVA in the "Manage Display" screen of your content type).
Comment #2
Fr0s7 commentedIf it works in the preview, then the source of your argument (contextual filter) is not getting picked up by the View.
I assume that you have two content types:
- Gallery (which acts as a container)
- Picture
All Picture nodes are "children" of the Gallery, and so they need a Reference which points to the Gallery node. Let's say your Reference field is named "parent", and it uses the Gallery node ID as its unique identifier.
In views, you want to attach a list of Picture nodes to their corresponding Gallery, using the "parent" field as the argument. It sounds like you have this much working so far.
Under "Advanced" In the Contextual Filters section, you should have one listed as the "parent" field (which contains the node ID for the Gallery you want to attach to. In the options for that filter, the first field group asks you to set options "When the filter value is NOT available". This should be set to "provide default value" and the type should be set to "Content ID from URL". By doing this, your views attached to your Gallery nodes will pick up the ID of that gallery and use it as an argument for your view.
But in order to get your view to show up, you need to edit the "Gallery" content type and look at the settings in the "Display" tab. You should see the name of your view listed among the other fields. If it's not there, click "Save" once and see if it appears. When it shows up, re-order it among the other fields as you like, and click "Save" again. You must do this for every display mode (default, Teaser, Full Node, etc.)
Now, your view should be properly attached to Gallery nodes, and the contextual filter from the URL should be getting picked up by the view.
NOTE: In order for the contextual filter to work based on Node ID, you need to be on a NODE page. In other words, this won't work on the homepage or "page" displays generated by Views because they aren't nodes and therefore don't have Node IDs.
Comment #3
mkadin commentedThanks folks. I'm going to close this as its been a while since we've heard from the author and these answers are both solid. We're working on dealing with these caching issues in the dev branch so we won't have to worry about #2 in the long run.