简体   繁体   中英

Relating different content types in Drupal 7

I've just started learning Drupal 7 and I'm stuck on a problem.

I want to relate different content types using taxonomy. For example, how can I display blogs related to an article? I know how to relate articles and basic pages but I don't know how can I relate blogs with articles?

Please help me.

Use reference field in blogs content type like

  • field name is: related with
  • field type is reference
  • set reference type node
  • set node type is article
  • optional multivalued true

Now you have a relationship field in blogs

Now you can do every thing with this relationship

Hope this make sense

Thanks

You would create your taxonomy vocabulary and supply it with terms. On its own, this doesn't do anything, you need to add a field to each of your content types that are using this taxonomy.

If you go back to your content types, structure > content type > article. Here you would create a new field of type term reference. Inside the settings of the field you'd select your vocabulary and then also the widget eg. select list. You can re-use this field on the other content types where you want to share this vocabulary.

If you go back to your content for the types you added this field for and populate them with selections, when you view that page by default the term will appear as a link. If you click this link it will take you to a page view that will list all the other nodes that have that term form that vocabulary.

More information on taxonomies: https://www.drupal.org/docs/7/organizing-content-with-taxonomies/about-taxonomies

If you are creating a view and want to know how to pull in different tagged content there, I'd recommend reading this post which outlines the steps to do so https://drupal.stackexchange.com/questions/205921/how-do-i-show-related-content

The process:

Basic stages:

 Create a “Content” view-block. Add a contextual filter: “Has taxonomy term ID”. Choose “provide a fixed value”. (From type): “Taxonomy term ID from URL“. 

Checking:

• Uncheck “Load default filter from the term page”. • Check “Load default filter from node page, that's good for related taxonomy blocks”.

• Check “Limit terms by a vocabulary”. • Check your desired vocabulary.

 Select “Filter to items that share any term”. Go down and check “Reduce duplicates”: This will several terms that relate to the same page – To appear. Only one will of them will. 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM