Hello,
I have embedded a views with the function views_embed_view. This view accept two arguments, that are a taxonomy Id and a cck text field with the content "ok".

So results are filtered by taxonomy id and if this cck field is filled or not.

I embed my view with

$argom =array("all" , "ok );
print views_embed_view("articolo_principale", "default", $argom ); 

?>
but I can't get any result. If I pass only the first argument, in this way

print views_embed_view("articolo_principale", "default", "7"); 

?>
it filters correctly.

So , I don't understand if the argument is passed right or not.

How can I see if the view "receive" the argument? Am I making mistakes with code?

Thanks,
Fabio

Comments

dawehner’s picture

<?php
$argom =array("all" , "ok );
print views_embed_view("articolo_principale", "default", $argom );
?>

This is not valid php, but anyway.

It should work. Did you tryed out in the preview, whether the two arguments works?

alexic’s picture

Well, if the problem was the " after ok, it was only a copy-problem.

Anyway, I tried in preview and it works. For default view, i pass all/ok or 31/ok and it works! But in my code it does not.

alexic’s picture

Status: Active » Fixed

Issue seems solved by passing multiple arguments in this way:


print views_embed_view("articolo_principale", "default", $first_arg, $second_arg, $third_arg ETC);

Status: Fixed » Closed (fixed)

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

2dareis2do’s picture

I have a view that has support for multiple arguments and one argument has multiple arguments

therefore I am trying to pass something like this


                      $view_name = 'package_by_grade_within_topic';
                      $display_id_default = 'default';
$first_arg2 = array(23996,79703,77617,88730,109201,90355,87751,87731);
                       $second_arg = 0;
                       $third_arg = $argtopic;
                       $fourth_arg = 2;
                       $string_arg_test  = array($first_arg2,$second_arg,$third_arg,$fourth_arg);

using

                    echo views_embed_view($view_name, $display_id_ref,  $string_arg_test);

I can currently use the view through the ui using something like this

23996+79703+77617+88730+109201+90355+87751+87731+97593/0/3933/2

as an argument to display the results I want. How do I pass this using views_embed_view ?

2dareis2do’s picture

something like this worked for me:

echo views_embed_view($view_name, $display_id_ref, $first_arg, $second_arg, $third_arg, $fourth_arg

First argument is input as a string i.e. $first_arg,$second_arg,$third_arg,$fourth_arg

$first_arg = "23996+79703+77617+88730+109201+90355+87751+87731+97573+87001";

or

$first_arg = "23996,79703,77617,88730,109201,90355,87751,87731,97573,87001";