1

I have menu links HOME | Property(links to property content type) | NEWS. In every News there are tags which reference to the property.

I want to link "NEWS" menu item to a separate page which should display only the news list which contains the tags for the property.

For example, i am on a property page say "Property XYZ", so there is a menu item "NEWS", when i click this menu item, a new page opens and this page is showing news which contain the Tag "Property XYZ" in them.

How do I achieve this?

2 Answers 2

1

From what i understand, These tags can be taxonomy terms and you can create a view where you can use contextual filter to get the tag name from url and show the related news content.

1)Page "Property XYZ" will have a link as abc.com/news/tag1
2)You can create the view page with path /news/%
3)News content should be already having those tags,so that you can get it from that view.

If this is not what you are looking for please provide more details.

EDIT:
1)https://www.drupal.org/project/pathauto
You can use this module to create patterns according to your need for your each news node path alias. You can use tokens of the taxonomy tag field to set those patterns.

For eg:
news/[node:title]/[node:field-news-category:1:name]
where field-news-category is the taxonomy reference field where you select tags terms

Now how to put these all these links in the menu is a different thing and that is up to you.

2)when you create a page view set path as /news/% (% for just a tag) OR /news/%/% (where first % can be news title and second can be tag)
% is the argument from url which is used in the contextual filter field

In right column of the view go to advanced and add a relationship field Content: Taxonomy terms on node then add contextual filter field as Taxonomy term: Term ID

There should be a default view as Taxonomy term,which will give you some idea to go about it. Play around a bit with contextual filters.

This might help,
Url Path Alias is not working with the "raw value from URL contextual filter"

1
  • Thanks @Tejas. Can you let me know about first two points that is how to make url like abc.com/news/tag1 (how to add news and tag1), and then how to get these parameters from url. i would like to use views on the news list page (a separate page will list down the relevent news) Commented May 24, 2016 at 14:03
0

If you're new to Drupal 7, one the fun surprises is that the query builder isn't in core (it finally was added in D8). You'll need to install the views module (which requires the ctools module, and a good tutorial will help). Given the description of your navigation you may want to have views create the property page as well.

  1. Make sure taxonomy, views, and views UI modules are all enabled.
  2. Create a vocabulary for your terms.
  3. Add a taxonomy field to both your News and Property types, and link it to the taxonomy you created in step 2.
  4. Create a few test pieces of content with shared terms (so you can test the view as you build it).
  5. Create a view that searches for nodes or type news. Create a page display. Without more than the default filters this will probably be a very reasonable general purpose news page.
  6. Create a block display on that view.
  7. To the block display add a contextual filter (third column) that filters by the taxonomy term ID, set the type to "Taxonomy term ID from URL", check the box labeled "Load default filter from node page, that's good for related taxonomy blocks", and then select the field you created in step 3.
  8. Go to the blocks display (or whatever module you are using to control block placement) and add your new view block to display on the property pages.

There will be details to tweak and massage but this should get you 80% of the way there. If you want the exact behavior you've described above, you could use a page display for the news listing that has a different setting on the context filter to filter by term name. Or you could update the taxonomy pages (again using views) to only show nodes of type news, and link directly from the property page (when you install views there are disabled views for the terms that you can modify to do exactly that if you want).

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.