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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davidwbarratt’s picture

Project: » Views (for Drupal 7)
Version: » 7.x-3.x-dev
Assigned: lv92 » Unassigned
babusaheb.vikas’s picture

It 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:--

  1. Click on add button next to Contextual filters for add your Contextual filters
  2. Select your field and click Apply(all display) button. or take a look on attached screenshot add_contextual_filter.png
  3. Now, Without any special setting click Apply(all display) button. or take a look on attached screenshot add_contextual_filter_next_step.png for reference.

Now the code should work.

$var = 7;
print views_embed_view('my_view', 'default', $var);

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.

MustangGB’s picture

Category: Bug report » Support request
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.