I have content type call car and a menu link to galleries.

I want each node created by car link to it's own gallery.

I was thinking of creating a view with the content type campus filter and a contextual filter

but I can't figure the menu part out, how do each menu under car know where it's own galleries is?

Really need help on this.

Many thanks in advance

Comments

Stefan Lehmann’s picture

It's quite hard to give some advice based on your vague description. If the gallery is a view and you need the current node id for a filter on the gallery view you could probably use a token to generate a link containing the current node id.

I like cookies!

xiaomo’s picture

Thank you for the quick reply and I apologize for the vagueness. I just want to clarify on a few things in the example below:

Let's say I created a node called ford focus 2014 with the content type "cars". In that node I will have a sidebar menu link to the gallery of ford focus 2014. I need to have this extra page because I want users able to contribute to the gallery.

I was thinking of creating a node gallery in which will be organized by views, and the problem is linking them together. How do I establish the link between the parent node ford focus 2014 and the gallery view?

I will have more than one car as parent obviously, there will be ford focus 2013, 2012 and so on, each will have their own gallery, is this doable?

I followed this guide below and add a menu path which is not working

create 'artist' and 'song' content types
in 'song' content type, create an 'entity reference' field using References module, choose autocomplete widget
in your artist content type click 'Generate automatic URL alias' under URL Path Settings
now set up your url pattern for artists (/admin/config/search/path/patterns) to artist/[node:title] or artist/[whateveryouwant]
create an artist first and then a song for testing (type the artist which the song references in the entity autocomplete reference field (it will include the artist Nid in parentheses)
create a view of songs and choose some fields, add a block display and name it
for the argument or 'contextual filter', choose your Content: Artist Reference field (appears in song)
In 'When the filter value is NOT available' choose 'Provide Default Value' and 'Raw value from URL' and then 2 for the path component
scroll down and where it says 'When the filter value IS available or a default is provided', choose 'Specify validation criteria' and basic validation as your validator

Thanks again

Stefan Lehmann’s picture

As stated in your example the gallery view will have to select / render it's results based on a contextual filter. This filter would probably be set via URL in your example.

So .. let's say your "ford focus 2014" node has the node nid = 13. The only thing you'd have to manage is to generate a gallery link on your "ford focus 2014" page which includes the current node nid, eg:

<a href="/car-galleries/13">View gallery</a>

There are multiple ways to accomplish that. You could do this with a contextual view itself (which only renders a link) or use tokens for instance.

The second step is to create a gallery view which has the path: car-galleries/% .. The % is the URL parameter used in the contextual filter. There is a lot of documentation around how to do this. You have to use the contextual filter which let's you grab a raw (nid) argument from the URL in which you can specify the location (first (1), second (2) etc.) in the filter settings.

Good luck!

I like cookies!

xiaomo’s picture

Thanks, I will take a look into it