I'm trying to embed a view on a node with the following code:
<?php
$view_args = array('all',1);
$display_id = 'page';
$view = views_get_view('news');
if (!empty($view)) {
print $view->execute_display($display_id, $view_args);
}
?>
The first argument ('all') is the wildcard I've selected in my view configuration. When this code runs, I get my empty message. I've tried passing an empty string, NULL and false, and I still get the empty message. How do I pass a wildcard as my first argument?
Thanks.
Comments
Comment #1
merlinofchaos commentedThe problem is likely your display ID. It is probably 'page_1', not 'page'.
Comment #2
sjancich commentedChanging the display_id to page_1 didn't alleviate the problem. I'm still getting empty text when I pass 'all' as the first argument. View returns as expected when an actual value is passed instead (but unfortunately, I don't want the embedded view to be limited by a real value in the first arg).
Comment #3
dawehnerYou have to execute pre_execute as well. I suggest to use $view->preview instead.
Comment #4
iamjon commentedsjancich hi,
I'm marking this as closed. Please feel free to re-open the issue if it has not been addressed.
You can also embed views in code following the steps here :
http://thedrupalblog.com/embedding-view-drupal-6-using-views-embed-view
Or using the views attach module