AnswerBun.com

View filtering, Relationship Vs Contextual filter

Drupal Answers Asked by Bassem Mohamed on November 15, 2021

I used contextual filters before and I know they are just like the normal filters but more dynamic, now I have this view “Sidebar Product advert block” that needs to show the product advert ( Similar to product teaser! advert is a view mode ) BUT only if the product is referenced in the field_product_teaser in the article data type. So to be more clear:


Articles have a reference entity (Autocomplete) field_product_teaser.

Products referenced in this field should appear in the sidebar!

So the condition is {{ product.Product-id == article.field_product_teaser }}


I hope that was clear enough, what should I use in this case ?? contextual filters? relationships? I tried using both with no luck!

One Answer

You should use the contextual filter to identify the article the block is being displayed on. E.g. content id from URL should work.

Then you should use the relationship option to link the field_product_teaser info to products. E.g. Content referenced from field ....

Then in the view, you can select the product fields you want to display and use the reference to tell views what you want displayed. E.g. title w/ product reference relationship = product title.

Answered by CG Monroe on November 15, 2021

Add your own answers!

Related Questions

“&” displaying as “&”

1  Asked on February 28, 2021 by mohk

     

Confirmation pop up on login submit

1  Asked on February 22, 2021 by vipin-p

   

Override a node page of specific content with views page

1  Asked on February 21, 2021 by hkguile

     

Hide Alt and Title for image field

2  Asked on February 20, 2021 by moto

       

How do I update from 9.0.10 to 9.1.0?

1  Asked on February 19, 2021 by user101999

   

Adding fields to content type edit form (not to the node itself)

1  Asked on February 18, 2021 by chris-riddell

 

Uploaded images in theme settings is going to be lost

3  Asked on February 13, 2021 by saidbakr

   

How to delete a large amount of nodes effeciently during cron?

1  Asked on February 12, 2021 by athakhan

   

Composer updates .htaccess file when updating

3  Asked on February 11, 2021 by albertski

   

How to print the Views title in page.tpl.php?

3  Asked on February 10, 2021 by szymon-panecki

   

May I use Bootstrap-CDN on Subtheme for production site?

1  Asked on February 7, 2021 by leelandra

     

Alter Webform email body

1  Asked on February 6, 2021 by lus

     

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP