Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_bonus/README.txt,v retrieving revision 1.2 diff -u -F^f -r1.2 README.txt --- README.txt 11 Sep 2006 16:45:09 -0000 1.2 +++ README.txt 27 Oct 2006 03:45:23 -0000 @@ -20,6 +20,9 @@ Panels: Teasers, 3 columns Requires panels.module -- like above, but merely left/middle/right alternating. + +Panels: By term, 3 columns + Requires panels.module -- terms presented as tables within columns such as http://sfbay.craigslist.org/. Bonus: Summary + full view Stacks a summary version of a view above a full view or additional Index: views_bonus.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views_bonus/views_bonus.module,v retrieving revision 1.2 diff -u -F^f -r1.2 views_bonus.module --- views_bonus.module 11 Sep 2006 15:35:20 -0000 1.2 +++ views_bonus.module 27 Oct 2006 03:45:24 -0000 @@ -32,6 +32,11 @@ function views_bonus_views_style_plugins 'theme' => 'views_bonus_panels_threecol', 'summary_theme' => 'views_summary', ); + $items['panels_threecol_term'] = array( + 'name' => t('Panels: By Term, 3 columns'), + 'theme' => 'views_bonus_panels_byterm_detail', + 'summary_theme' => 'views_bonus_panels_byterm_summary', + ); } $items['summary_combo'] = array( 'name' => t('Bonus: Summary + full view'), @@ -48,6 +53,7 @@ function views_bonus_views_style_plugins } return $items; } + // -------------------------------------------------------------------------- // Plugin themes /** @@ -156,6 +162,52 @@ function theme_views_bonus_panels_threec } return panels_print_layout('threecol_33_34_33', $content); } + +// inspired by the the 3 column classifieds in the middle section of http://sfbay.craigslist.org/ +function theme_views_bonus_panels_byterm_summary($view, $type, $items, $level, $args) { + // argument 0 must be a vocabulary ID + $vid = $view->args[0]; + $tree = taxonomy_get_tree($vid); + // group terms with their parent + foreach ($tree as $term) { + $cnt = taxonomy_term_count_nodes($term->tid); + $txt = array(_taxonomy_depth($term->depth). ' '. l($term->name, "$view->real_url/$term->tid"). " ($cnt)"); + if ($term->depth == 0) { + $parent_tid = $term->tid; + $groups[$parent_tid]['header'] = $txt; + } + else { + $groups[$parent_tid]['rows'][] = $txt; + } + } + + // render the groups into tables spread across 3 columns + $content = array(); + $i=0; + foreach ($groups as $group) { + switch ($i % 3) { + case 0: + $section = 'left'; + break; + case 1: + $section = 'middle'; + break; + case 2: + $section = 'right'; + break; + } + $content[$section] .= theme('table', $group['header'], $group['rows']); + $i++; + } + return panels_print_layout('threecol_33_34_33', $content); +} + +function theme_views_bonus_panels_byterm_detail($view, $nodes, $type, $level = NULL, $args = NULL, $summary = FALSE) { + $teasers = true; + $links = true; + return theme('views_view_nodes', $view, $nodes, $type, $teasers, $links); +} + // -------------------------------------------------------------------------- // Combo theme with summary on top and full view below /** @@ -506,5 +558,74 @@ function views_bonus_views_default_views $view->requires = array(term_lineage, node); $views[$view->name] = $view; } + + if (module_exist('panels')) { + $view = new stdClass(); + $view->name = 'panels_by_term'; + $view->description = 'Standard taxonomy presentation except the summary view presents terms within narrow tables in a 3 column layout like http://sfbay.craigslist.org/.'; + $view->access = array (); + $view->view_args_php = ''; + $view->page = TRUE; + $view->page_title = 'panels_by_term'; + $view->page_header = ''; + $view->page_header_format = '1'; + $view->page_footer = ''; + $view->page_footer_format = '1'; + $view->page_empty = ''; + $view->page_empty_format = '1'; + $view->page_type = 'panels_threecol_term'; + $view->url = 'panels_by_term'; + $view->use_pager = TRUE; + $view->nodes_per_page = '10'; + $view->sort = array ( + array ( + 'tablename' => 'node', + 'field' => 'sticky', + 'sortorder' => 'DESC', + 'options' => '', + ), + array ( + 'tablename' => 'node', + 'field' => 'created', + 'sortorder' => 'DESC', + 'options' => '', + ), + ); + $view->argument = array ( + array ( + 'type' => 'vocid', + 'argdefault' => '1', + 'title' => '%1', + 'options' => '', + 'wildcard' => '', + 'wildcard_substitution' => '', + ), + array ( + 'type' => 'taxid', + 'argdefault' => '6', + 'title' => '%1 - %2', + 'options' => '9', + 'wildcard' => '', + 'wildcard_substitution' => '', + ), + ); + $view->field = array ( + array ( + 'tablename' => 'node', + 'field' => 'title', + 'label' => '', + 'handler' => 'views_handler_field_nodelink', + 'options' => 'link', + ), + ); + $view->filter = array ( + ); + $view->exposed_filter = array ( + ); + $view->requires = array(node); + + $views[$view->name] = $view; + } + return $views; } \ No newline at end of file