I use

$view = views_embed_view('export_emargement','page_1',$journee,$region,$produit);

it works well, but If I don't want to specify $region the view does'nt works.

Im my view admin if I set argument like this 797/62/24 it works

If I try 797/all/24 it works too!every data are displayed

In my code i try this, but it can't be parsed

$args = array($journee.',"all",'.$produit);
$args = array($journee.',all,'.$produit);
$view = views_embed_view('export_emargement','page_1',$args);

$args is an array that expects each field's contextual values to be passed in separately.

i think $args = array($journee, "all", $produit); ought to work.

you should only concatenate arguments into a string if its a multi-value single field situation and then I believe you join with '+' not commas.


I missed what you were asking, if you have a contextual filter that is optional inside the view you can configure what happens when no value is provided (pick "display all results").

configuration form for contextual filter

then when calling the view

as far as skipping an argument 'all' - the easiest way would be to move the order of the contextual filters so that the one that is allowed to be "empty" is last.

then instead of calling

$view = views_embed_view('export_emargement','page_1',$journee,$region,$produit);


$view = views_embed_view('export_emargement', 'page_1', $journee, $produit, $region);


$view = views_embed_view('export_emargement', 'page_1', $journee, $produit);

depending on if the user has selected a region

  • Hello, thanks for your answer. I alreday test : $view = views_embed_view('export_emargement','page_1', $arg1, $arg2, $arg3); it works but if I need all values I need to use $view = views_embed_view('export_emargement','page_1', $arg1, 'all', $arg3); and this one doesn't work.. – cnatale May 16 at 7:09
  • OK, it works when I move the argument "region" at the end, but sometimes $produit is null and region is set, so I find a solution by creating different pages and I call her depending on the arguments values... – cnatale May 17 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.