I want to print a couple of views on one page. I'm using this

$view1 = views_get_view('article_queue_large/1');
//output the view
print views_build_view('embed', $view1);

My view has url value of article_queue_large and takes a queue id as an argument.

I can view different nodequeues thanks to the argument, but I don't know how to pass the argument into the embeded view.

Can an embed view take arguments?

Comments

jmlavarenne’s picture

Status: Active » Closed (fixed)

Silly me - I was using the page view url instead of the view name as the function argument... case closed!

jmlavarenne’s picture

Status: Closed (fixed) » Active

Finaly while I solved one issue, it seems I do have a problem passing arguments to embeded views.

I can pass the argument '1' like this:

//load the view by name
$view1 = views_get_view('large_teaser_queue');
//output the view
print (views_build_view('embed', $view1, '1'));
print_r ($current_view->args);

I can pass the argument '2' like this:

//load the view by name
$view1 = views_get_view('large_teaser_queue');
//output the view
print (views_build_view('embed', $view1, '2'));
print_r ($current_view->args);

But if I try to pass the argument '17' like this:

//load the view by name
$view1 = views_get_view('large_teaser_queue');
//output the view
print (views_build_view('embed', $view1, '17'));
print_r ($current_view->args);

The view reacts as if I had passed the argument '1'.

Does this parameter only take into consideration the first character of the argument?

merlinofchaos’s picture

Status: Active » Fixed

arguments should be an array()

jmlavarenne’s picture

Got it! Thanks.

In case someone else searches for this late at night :

$view2 = views_get_view('double_teaser_queue');
//output the view
$args[0] = '17';
print views_build_view('embed', $view2, $args);
Anonymous’s picture

Status: Fixed » Closed (fixed)

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