0

I have a Page created using a View using a Content Type called Sectors, which displays rows of images with a title underneath the image. The Sector content type has the fields - Title, Image, Sector Category (uses a Taxonomy). A Sector can have many Projects.... so.....

When the user clicks on the Sector Image or Title, i want my site to go to another Page which is created using a View and display all the Projects belonging to that Sector using the Sector Category field (which is a field on both Sector and Projects content type, passed to it from the previous Sectors page), to select all the Projects that are held in the Projects Content Typle - which has fields Title, Image, Sector Category.

How can I link the 2 views?

1 Answer 1

2

You first need to create your other page, using Views, with a path pattern similar to the following:

projects_by_sector/%tid

This page can then be configured to display only content of type Projects and the fields you need (Title, Image, Sector Category, etc). Most importantly, you need to configure a contextual filter with the following configuration:

  • For the "Content: Sector Category" field
  • "Provide default value"
  • "Raw value from URL"
  • "Path component" => 2 (this follows from the example URL above)

Now back in your existing Views page for the Sectors list, you need to do some field rewriting. This can be done in a number of ways, the easiest would be to add the Sectors Taxonomy reference again as a field and do the rewriting on that field. You can do these using the following steps:

  • Add the "Content: Sector Category" field
  • Save with the default configuration
  • Rearrange your fields and move the new field below/after the "Content: Title" field. This is important so that the replacements token [title] will be available for the rewriting.
  • Hide the "Content: Title" field by selecting "Exclude from Display" on its configuration
  • Configure the new "Content: Sector Category" field
  • Select "Plain text" as "Formatter"
  • Expand "Rewrite Results"
  • Select "Rewrite the output of this field"
  • Enter the following in the "Text" textarea to use the title of your sector
    [title]
  • Select "Output this field as a link"
  • Enter the following as the "Link path"
    projects_by_sector/[field_sector_category-tid]

This is a rough idea, you need to tune your views page accordingly, but the end-result should be what you asked for. Hope this helps!

8
  • In my Sector List View, I have 3 fields selected - Sector Image, Title, and now I have Sector Category. I have set Sector Category so that it Excludes from Display ticked, Output this Field as a Link ticked, Link Path set as projects-by-sector/[field_sector_category-tid] . I have also changed the settings for the Sector Image and Title so they do nothing (i.e. don't link to Content). On my site, now when I hover over a Sector image to click and select one, it does nothing. Commented Mar 20, 2016 at 15:57
  • I read your question again, it seems that you want to use the Sector's Title or the Sector's Image as the link to the Sector's projects list. I suggested an additional field for that. Is that an option for you? Otherwise, I will update my answer accordingly and specifically for using the Sector's Image as a link. Commented Mar 20, 2016 at 16:39
  • Yes, I want to use the Sectors Title or Image to link to the Projects View using the Sector Category . thanks Commented Mar 20, 2016 at 16:43
  • I updated my answer. Commented Mar 20, 2016 at 16:57
  • when Im configuring the Projects by Sector View, I have added a Contextual Filter for Sector Project Category as specified above, Default Value ticked , Raw value from URL ticked, Path Component = 2. This results in nothing being displayed in the Preview at the bottom of the view. If I select "Display all results for the specified field " then all the projects appear. Is it because Sector Project Category is a taxonomy term and needs different configuration? Commented Mar 20, 2016 at 17:38

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.