I have about three views that will be used; Here's Daniel Wehner's answer:

 $view = views_get_view(); 
 $view->filter['foo']->value = 'bar'; 
 print $view->preview($display_id, $args);

I built this based off his code, which while works, could be improved if including views is going to be a regular activity throughout your project:

$view = views_get_view('nodequeue_3');

$content['raw_markup'] = array(
  '#type' => 'markup',
  '#markup' => $view->preview(),

I'm also thinking this might not be done that often, because if you can build a module, why use views?

The utility of views should not be overlooked, in combination with (or without) a custom module.

Thanks for the patience, this community is awesome!

  • 2
    Try views_embed_view()? – GrayB Mar 8 '12 at 3:11

I prever to use this small helper function:

function mymodule_embed_view($view_id, $display_id, $arguments) {
    $view = views_get_view($view_id);
    return $view->render();

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.