I have a related_news view that uses a taxonomy name argument. I am embedding this view in a template. Apart from the fact that the view title doesn't render (the subject of another post: http://drupal.org/node/141820) , it works fine if I am only passing in one taxonomy name.

But I want to be able to get related news for multiple taxonomy terms. Do I need to create separate arguments to pass in multiple terms? Or can I pass multiple terms to the same argument? If the latter, how do I do this?

Right now, my code looks like this:

$myview_args = array(0 => $my_topic );
print views_build_view('block', $myview, $myview_args, false, 4);

$my_topic above is a taxonomy term name. I would like to pass in two or more names and get all the related nodes back.

Would really appreciate the help. Thanks.

Comments

Perhaps you can get it working with Arguments Handling Code.
The views fusion module may help too.

Bumping.

I have searched for the answer in vain.

I have also tried doing my settings through filters rather than arguments. This doesn't work either.

Hasn't anyone tried to dynamically set their filters during embedding?

Instead of using an argument for my term name, I switched to filters since it allows for multiple values. I added a filter for the taxonomy term and a filter for the node type. I exposed the filters. It seemed that if I didn't expose them, I couldn't change their settings dynamically.

After doing this my embedding code ending up like this:

    $myview = views_get_view('related_news'); //retrieve view using view name.
    $myview->filter[0]['value'] = array (0 => '15', '27', ); // set the taxonomy ids for the first filter
    $myview->filter[1]['value'] = array (0 => 'story',); // set the node type via the second exposed filter.
    print views_build_view('block', $myview, array(), false, 4) ; // show the view in the page.

I checked and it seems that using term name seems to be limited to one argument:
http://drupal.org/node/77543

Conversely, using TID is enhanced to work like this:
http://(site).com/taxonomy/term/253+145

But you are in the right path by using the views API.
Using two dynamic filters of TID work, as you note, but using term names might fail again.

If everything else fail, try using sql queries directly, using query_alter, like this:

function views_views_query_alter(&$query, $view, $summary, $level) {
$query->add_where("%s.%s LIKE '%%%s%%'", array('node_data_field_name', 'field_name_value', $name));
}//endf

I just submitted a patch to fix this in views.
http://drupal.org/node/77543#comment-633801