Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change the HTML of the drupal 5's views module
    primarykey
    data
    text
    <p>I'm using Drupal 5 and have a multitude of views that I want to alter the output of. Using the views wizard, I can create a different template for each instance, but I'm wanting to do the same changes across all my views and having 30 files in the themes directory seams like a hell of a lot of maintenance and code. Does anyone know if there's a default way of addressing all the views at the same time and then using what I currently have for one offs?</p> <p>Here's what I have now:</p> <p>views-list-home_______articles_______latest.tpl.php</p> <pre><code>&lt;?php /** * views template to output one 'row' of a view. * This code was generated by the views theming wizard * Date: November 17, 2008 - 2:07pm * View: home_articles_latest * * Variables available: * $view -- the entire view object. Important parts of this object are * home_articles_latest, . * $view_type -- The type of the view. Probably 'page' or 'block' but could * also be 'embed' or other string passed in from a custom view creator. * $node -- the raw data. This is not a real node object, but will contain * the nid as well as other support fields that might be necessary. * $count -- the current row in the view (not TOTAL but for this page) starting * from 0. * $stripe -- 'odd' or 'even', alternating. * $title -- Display the title of the node. * $title_label -- The assigned label for $title * $comment_count -- This will display the comment count. * $comment_count_label -- The assigned label for $comment_count * $field_abstract_value -- * $field_abstract_value_label -- The assigned label for $field_abstract_value * * This function goes in your views-list-home_articles_latest.tpl.php file */ //now we add the stylesheet... //drupal_add_css(path_to_theme() .'/views-list-home_articles_latest.css'); ?&gt; &lt;?php print $view ?&gt; &lt;div class="view-label view-field-title"&gt; &lt;?php print $title_label ?&gt; &lt;/div&gt; &lt;div class="view-field view-data-title"&gt; &lt;?php print $title?&gt; &lt;/div&gt; &lt;?php if ($comment_count != '0' &amp;&amp; $view_type == 'block'): ?&gt; &lt;div class="view-label view-field-comment-count"&gt; &lt;?php print $comment_count_label ?&gt; &lt;/div&gt; &lt;div class="view-field view-data-comment-count"&gt; &lt;?php print $add?&gt;&lt;?php print $comment_count?&gt; &lt;/div&gt; &lt;?php endif; ?&gt; &lt;?php if ($count == 0): ?&gt; &lt;div class="view-label view-field-field-abstract-value"&gt; &lt;?php print $field_abstract_value_label ?&gt; &lt;/div&gt; &lt;div class="view-field view-data-field-abstract-value"&gt; &lt;?php print $field_abstract_value?&gt; &lt;/div&gt; &lt;?php endif; ?&gt; </code></pre> <p>in template.php</p> <pre><code>/** * views template to output a view. * This code was generated by the views theming wizard * Date: November 17, 2008 - 2:07pm * View: home_articles_latest * * This function goes in your template.php file */ function phptemplate_views_view_list_home_articles_latest($view, $nodes, $type) { $fields = _views_get_fields(); $taken = array(); // Set up the fields in nicely named chunks. foreach ($view-&gt;field as $id =&gt; $field) { $field_name = $field['field']; if (isset($taken[$field_name])) { $field_name = $field['queryname']; } $taken[$field_name] = true; $field_names[$id] = $field_name; } // Set up some variables that won't change. $base_vars = array( 'view' =&gt; $view, 'view_type' =&gt; $type, ); foreach ($nodes as $i =&gt; $node) { $vars = $base_vars; $vars['node'] = $node; $vars['count'] = $i; $vars['stripe'] = $i % 2 ? 'even' : 'odd'; foreach ($view-&gt;field as $id =&gt; $field) { $name = $field_names[$id]; $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view); if (isset($field['label'])) { $vars[$name . '_label'] = $field['label']; } } $items[] = _phptemplate_callback('views-list-home_articles_latest', $vars); } if ($items) { return theme('item_list', $items); } } </code></pre> <p>Thanks,<br /> Steve</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload