Trying to theme title fields in all views across the site, I created a views-view-field--default--title.tpl.php file, put it in the theme folder -- and nothing happens. When I select the Defaults tab on the Views editing page, I can see the the template under Theme:Information. However when I select a Page or other display, the template is not discovered.
The culprit appears to be this piece of code in handlers/views_handler_field.inc:
<?php
if (!empty($display)) {
$themes[] = $hook . '__' . $this->view->name . '__' . $display->id . '__' . $this->options['id'];
$themes[] = $hook . '__' . $this->view->name . '__' . $display->id;
$themes[] = $hook . '__' . $display->id . '__' . $this->options['id'];
$themes[] = $hook . '__' . $display->id;
?>
As far as I understand the code, $display->id is either a specific display ID (e.g. page_1), or 'default'. So if I have defined a display in my view, $display->id is not 'default', and I'm not going to have views-view-field--default, views-view-field--default--title etc. in the $themes array ever.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | views-322214.patch | 1.62 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) commentedIt appears to have fixed my site, but probably there's a better way to do it.
Comment #2
merlinofchaos commentedI think you misunderstand how this works. 'default' only applies to the default display, this is the intended behavior. If you want it to apply to all displays in the view, just use
views-view-field--viewname.tpl.phpor leave the display id out.Comment #3
Anonymous (not verified) commentedThanks for the quick response.
views-view-field--viewname.tpl.phpisn't a very good option on a large site with many views.Sorry, I don't understand. Do you mean
views-view-field--title.tpl.phporviews-view-field----title.tpl.php? As far as I see, neither works.Basically, I'm looking for the Views 2 equivalent of
phptemplate_views_handle_field_node_title($fields, $field, $data). It was a wonderful function that I used all the time to make views more SEO friendly (i.e. wrap <h3> tags around all node title fields in my views, etc.).Comment #4
merlinofchaos commentedThis should work:
views-view-field--title.tpl.phpOk, so I just noticed the above isn't actually in the list, and it should be. I just fixed the code in CVS so that it is one of the possibilities.
Note that all of the possibilities are listed on the theme: information page, so there isn't any need to guess.
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.