How do I render a view in views 2.x? Can you tell us some of the exposed methods or how we can figure them out (sorry I'm not too experienced in this stuff).

In views 1.x I am able to do this:

$view = views_get_view('my_view');	
$rendered = views_build_view('embed', $view, NULL, FALSE, NULL);
print $rendered;

But views_build_view is no longer a function... how do I do this?

Comments

merlinofchaos’s picture

Status: Active » Fixed
merlinofchaos’s picture

Err, http://views.doc.logrus.com -- dunno where that f came from. :P

moshe weitzman’s picture

Title: Exposed methods in views 2.x » Embedding a View in views 2.x
Status: Fixed » Active

Also see http://groups.drupal.org/node/10129.

@merlin - consider adding an Embed link like you did for 'Theme: information'. It would have some example embed code.

merlinofchaos’s picture

I'm not sure I want to put embed code as part of the view information stuff; but more documentation on the topic could be valuable, I suppose.

merlinofchaos’s picture

Oh, there's also the very helpful function views_embed_view() -- meant ot make it very easy to embed a view using the preview() functionality.

merlinofchaos’s picture

Title: Embedding a View in views 2.x » Create a help page for embedding a view in the views advanced help
Category: support » task

Changing title to reflect what needs to happen here.

brad.bulger’s picture

It would be very helpful to have some documentation somewhere about how to convert calls to views_build_view() to views 2.x. Specifically, how to achieve the same effects as using the old $use_pager, $limit, $page, $offset, $filters arguments. If this is already written, then maybe including a link in the documentation for views_embed_view()? Or some kind of "Upgrading embedded view calls" or suchlike? I cannot find anything like this. Thanks.

dawehner’s picture

Issue tags: +Novice

Add tag

esmerel’s picture

Component: Code » Documentation
Assigned: Unassigned » esmerel
iamjon’s picture

Version: 6.x-2.0-beta2 » 6.x-3.x-dev
Status: Active » Needs review
StatusFileSize
new961 bytes

There is a an advanced help page for this already:
http://views-help.doc.logrus.com/help/views/embed

If it is not sufficient I created a patch that borrows heavily from here:
http://thedrupalblog.com/embedding-view-drupal-6-using-views-embed-view
And expands the existing example...

I'm not too sure it's necessary though.

dawehner’s picture

Assigned: esmerel » iamjon
Status: Needs review » Needs work

Oh this example code is sadly wrong. It should be

+print views_embed_view($viewName, $display_id, 1, 2, 3);
iamjon’s picture

StatusFileSize
new923 bytes

Thanks dereine,

So the arguments must be passed as strings not an array?
Patch attached.

iamjon’s picture

Status: Needs work » Needs review

Change status

dawehner’s picture

This is better.

esmerel’s picture

Status: Needs review » Fixed

This appears to already have been committed in 6.x-3.x

Status: Fixed » Closed (fixed)
Issue tags: -Novice

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