测试通过版本:
drupal6.22
views6.x-2.12
首先在view编辑页面,点击Theme: Information,找到要应用的模板
如views-view-field--members-listing--name.tpl.php
然后在自定义模块目录下创建该模板文件,可以从views模块下复制相关文件然后重命名。
然后在自定义模块的module文件中应用hook_theme,注册自定义模板。
代码如下:
/**
* Implementation of hook_theme
*/
function my_module_theme() {
return array(
'views_view_field__members_listing__name' => array(
'template' => 'views-view-field--members-listing--name', //注意:这个地方不能带后缀.tpl.php
'path' => drupal_get_path('module','my_module'),
'arguments' => array('view' => NULL, 'field' => NULL, 'row' => Null),
'original hook' => 'views_view_field',
'type' => 'module',
'preprocess functions' => array('template_preprocess', 'template_preprocess_views_view_field'),
),
);
}
然后在views编辑页面的Theme: Information下点击Rescan template files,这时我们自定义的模板应该就处于选中状态了。
然后点击 OK , 再点击Save 保存view。
这样我们的自定义模板就应用上了。