Experimenting with Drupal 6.x with views 6.x-2.x module... I could use your help with implementation:

I need a hierarchical sidebar menu for lots of content, so I'm using Book Page as my main content type, rather than Page, and I utilize the Book Navigation block to get the content menu. Now I've run into a conundrum:

One of my books is an About Us book, with multiple book pages. I also have a view set up that returns a grid with user/member information by role (for departments) from profile fields. So far so good, but I can't seem to locate a way to display the views page results as a book page, so it can show up under the Book Navigation menu hierarchy. Any ideas?

Is there a clean way to include a view in a book page in Drupal 6.x, or is there a better way of doing hierarchical menus than using book pages/book navigation? The site users will be adding additional pages, so the Book concept seems like the right approach, as the navigation is already built-in.

Thanks in advance for your help...

Comments

drubeedoo’s picture

Found a section on Inserting Views for Drupal 5.x, but nothing so far on 6.x... The Views 2.x API seems to have changed.

[edit]

OK, for anyone interested (while the Views 2.x documentation is still under development) the following PHP code snippet should embed a view into any node body text via the PHP filter:

<?php
    // Load the view by name
    $view = views_get_view('example_view_name');
    // Output the view
    print $view->execute_display('embed', $view);
?>
gbrussel’s picture

You can also test out the Insert View module. I've tried it on a D6.3 install, seems to work fine.

drubeedoo’s picture

I'll give it a look-see... The Insert View module wasn't available for D6.x at the time I was looking to embed Views 2.x.

kpm’s picture

I'm trying to dump a view of a list of holidays in a book page, it does display, but also comes with the following warning on the top of the page:

warning: array_merge() [function.array-merge]: Argument #2 is not an array in /sites/all/modules/views/includes/view.inc on line 1163.
warning: implode() [function.implode]: Invalid arguments passed in /sites/all/modules/views/includes/view.inc on line 1165.

Any idea what may be the cause?
Its a view created from an event content type I created.
Thanks!

PeterZ’s picture

Another option (for Views 2 in Drupal 6.x) is to use:

function views_embed_view($name, $display_id = 'default')

$name = name of the view (machine name with no spaces)
$display_id = (see below)

To figure out the id of a display, hover your mouse over the tab to select that display. Everything after the '#views-tab-' is the id of that display. This ID is guaranteed never to change unless you delete the display and create a new one.

From: http://views-help.doc.logrus.com/help/views/embed

kpm’s picture

I've attempted this with an event view from an event content type I created...

Parse error: syntax error, unexpected $end in .../includes/common.inc(1695) : eval()'d code on line 3

I added the following to a book page using the php filter:

<?php
function views_embed_view($holidays, $display_id = 'views-tab-page_1') {
?>

Same thing happens with

<?php
function views_embed_view($holidays, $display_id = 'default') {
?>

Any ideas what it is I'm missing?
Thanks!