Hi,

I've just updated my site from Drupal 5 to 6.
I got a View called 'gallery' and to override the output of block, I used the following function on D5.

function phptemplate_views_view_gallery($view, $type, $nodes) {
	$fields = _views_get_fields();
	foreach ($nodes as $node) {
	          ..................................................
	}
return $output;
}

But, In drupal 6, I used the following code in template.tpl.php

function mythemename_preprocess_views_view__gallery(&$variables) {
  $variables['foo'] = 'Hello World';
}

and created a new template called 'views-view--gallery.tpl.php' in my theme directory.

if ($foo) {
  print $foo;
}

It is 'unformatted' style. I've already cleared 'cache' under Admin>>Performance.
But, It doesn't work.... I can still see the default one. I don't see 'Hello World' text on 'gallery' views.
I'm not sure I'm doing right. Can anyone help me please?
Many Thanks in advance.

Comments

peti2006@googlemail.com’s picture

sorry, it was my stupid mistake. Actually, I was looking into wrong template.
It's working now..

peti2006@googlemail.com’s picture

Another question.
Actually I also have to override individual fields of Views.
eg., in Drupal 5, I can easily know node ID ($i) of each row.

function phptemplate_views_view_gallery($view, $type, $nodes) {

	$fields = _views_get_fields();
	$output .= '<div id="info"></div><ul id="test-list">';
	foreach ($nodes as $node) {
		$item = "";
		$i = $node->nid;
		foreach ($view->field as $field) {
			$item .= views_theme_field("views_handle_field",$field['queryname'], $fields, $field, $node, $type);
		}
		$output .= '<li id="listItem_'.$i.'"><div class="handle" />'.$item.'</div></li>';
	}
	$output .= '</ul>';

return $output;
}

All I want to do is to add css (id="listItem_'.$i.'")
But, in Drupal 6, how can I know nodeID of each row in views-view-list--VIEWNAME.tpl.php ?