Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using Drupal 7.24 .
The problem is that:
I have one view with one contextual filter.
This contextual filter if is not defined will show everything .
print views_embed_view('my_view','default'); // ✔ all shown
This views_embed_view works without contextual filter.
If i pass one contextual filter to views_embed_view as follow:
$var = 7;
print views_embed_view('my_view','default',$var);
the view won't read $var as contextual filter.
I tried with dpm but it says that there are no problem :S.
Comment | File | Size | Author |
---|---|---|---|
#2 | add_contextual_filter_next_step.png | 37.39 KB | babusaheb.vikas |
#2 | add_contextual_filter.png | 22.49 KB | babusaheb.vikas |
Comments
Comment #1
davidwbarratt CreditAttribution: davidwbarratt commentedComment #2
babusaheb.vikas CreditAttribution: babusaheb.vikas commentedIt seems there are some problem in the way you have set your contextual filter.
Follow 3 simple steps to pass argument as Contextual filters in view:--
Now the code should work.
Note:-- if you assign value 7 in $var and pass as argument, its necessary that 7 should be the true value of your contextual filter. True value in the sense if you add taxonomy term as contextual filter, 7 should be your term id of taxonomy vocabulary related to your contextual filter. it may be cause that view won't read $var as contextual filter.
Comment #3
MustangGB CreditAttribution: MustangGB commented