Example: How to Display a Summary View as a Mock Menu
Last modified: February 16, 2008 - 04:18
On the surface, this looks like it's just a 'simple' list. But it turns out it isn't quite so simple, because to do a menu properly, you need to modify the link returned. Which means you need to actually know a little bit about how views_get_summary_link functions. A little code exploration is required to properly write this, but luckily, you're reading an example and that code exploration was already done for you.
This used to be a bit more complex, but has actually simplified quite a bit.
<?php
function phptemplate_views_summary_VIEWNAME($view, $type, $level, $nodes, $args) {
$list = '';
foreach ($nodes as $node) {
$list .= '<li class="leaf">' . views_get_summary_link($view->argument[$level]['type'], $node, $view->real_url) . "</li>\n";
}
if ($list) {
return "<div class='menu'><ul>$list</ul></div>";
}
}
?>