Drupal 7: how to filter view content (with entity reference field) based on current page content -
Drupal 7: how to filter view content (with entity reference field) based on current page content -
in drupal 7 have 2 content-types these:
contenta contentb (with field entity reference contenta)in front-end detail page of contenta, love show block/view list of contentb entity reference field set current contenta.
i made view of type block , added correctly page, cannot filter contentb based on current contenta.
could help me?
thanks
you should add together contextual filter value utilize filtering block view of contentb. in contextual filter in "when filter value not in url" area select "provide default value" , type "php code" (you should have enable php filter this). in php code area should have next code
$node=menu_get_object(); homecoming $node->field_your_machine_field_name['und'][0]['target_id']; // field utilize fitlering
hope helps
update
the above code work if need show in block similar results same selection (for illustration similar results of contentb same selection in referencing field of contenta ).i not delete because might need in project.i misunderstood. solution simpler. should add together contextual filter field , in "when filter value not in url" area select "provide default value" , "provide id url"
drupal drupal-7 drupal-views drupal-blocks entityreference
Comments
Post a Comment