/[drupal]/contributions/modules/themer/viewsthemer.module
ViewVC logotype

Diff of /contributions/modules/themer/viewsthemer.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3, Wed Jan 7 13:09:20 2009 UTC revision 1.4, Wed Jul 1 03:44:05 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: viewsthemer.module,v 1.2 2008/12/29 02:49:40 bevan Exp $  // $Id: viewsthemer.module,v 1.3 2009/01/07 13:09:20 bevan Exp $
3    
4  /**  /**
5   * @file Views Themer   * @file Views Themer
# Line 50  function viewsthemer_theme_registry_alte Line 50  function viewsthemer_theme_registry_alte
50   * Theme views with one linked title field with theme_links()   * Theme views with one linked title field with theme_links()
51   */   */
52  function viewsthemer_preprocess_views_view_unformatted(&$vars) {  function viewsthemer_preprocess_views_view_unformatted(&$vars) {
53    foreach ($vars['classes'] as $key => $value) {    extract($vars);
54      foreach ($classes as $key => $value) {
55      // Add classes to every row.      // Add classes to every row.
56      $vars['classes'][$key] .= ' views-row clear-block';      $vars['classes'][$key] .= ' views-row clear-block';
57    }    }
58    
59    // If this view is just a list of links, then theme as a menu, aka list of links.    // If this view is just a list of links, then theme as a menu, aka list of links.
60    $vars['view']->field;    if (count($view->field) == 1 and isset($view->field['title'])) {
61    if (count($vars['view']->field) == 1 and isset($vars['view']->field['title'])) {      $title = $view->field['title'];
     $title = $vars['view']->field['title'];  
62      if ($title->table == 'node' and $title->real_field == 'title' and $title->options['link_to_node']) {      if ($title->table == 'node' and $title->real_field == 'title' and $title->options['link_to_node']) {
63        // Build a list of theme_links()-compatible links.        // Build a list of theme_links()-compatible links.
64        $links = array();        $links = array();
65        foreach ($vars['view']->result as $i => $row) {        foreach ($view->result as $i => $row) {
66          // The key of the array becomes the class of the <li>          // The key of the array becomes the class of the <li>
67          $class = $vars['classes'][$i];          $class = $vars['classes'][$i];
68          $links[$class] = array('href' => "node/$row->nid", 'title' => $row->node_title);          $links[$class] = array('href' => "node/$row->nid", 'title' => $row->node_title);
69        }        }
70        $vars['links'] = theme('links', $links, array('class' => 'viewsthemer menu'));        $vars['output'] = theme('links', $links, array('class' => 'viewsthemer menu'));
71      }      }
72    }    }
   // @todo:  Check for views with one field, and views with one item (e.g. home page)  
73  }  }
74    
75  // An alias for views-view-unformatted, since they use the same preprocess.  // An alias for views-view-unformatted, since they use the same preprocess.

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2