My problem is that SOMETIMES (~1/20 times) the view doesn't find the template file.
I have no idea exactly why this happens but it seems to happen after something has been saved, like a node or a view (any node or view).

Maybe it is relevant to tell you about how I have done.
I have 2 views:

- view1 (page display) simply works as a container for view2.
it embeds view2 (which contains the real content) so view1 is just a page with a node containing settings for view2.
- view2 is a list of nodes along with a pager.

So when I go to the path of view1 I come to view1's template which embeds view2.
It works just like I want it to work besides it doesn't always work :)

The way I know that the problem is that the two views doesn't find their template files is that the way the page looks when this happens is just how it looks when I delete/rename these template files of the views.

I hope someone can help me with this because I have no idea how to solve this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

akahn’s picture

Category: bug » support
Priority: Critical » Normal

Can you try to explain more clearly what you're trying to do with your two Views and what the issue is exactly?

merlinofchaos’s picture

Template file registration is handled by the Drupal core theming system, not Views itself. When you find yourself in this situation, you can use something like devel.module to peer into the theme registry and see if that template is somehow not registered. I've never heard of that happening, though.

This isn't something that I can just magically answer, though. I have no idea why something like this is happening.

dwees’s picture

I think I have noticed when this happens. Is it possible that if you create a template file in your theme directory that is exactly the same name as the current template file stored in the views module theme subdirectory, and you rescan the templates that the Drupal theme layer continues to use the old template? I seem to remember noticing this a couple of days ago.

Mattias Holmqvist’s picture

This devel theme information was given to me when it all worked as it should so I have not yet tried it when it bugs. But judging from how it looks when it bugs it seems like view1 uses page.tpl only.

Thanks for the tips.
I'm not really sure what you mean by theme registry but I guess it is what I see when checking the devel box "themer info" which opens the "drupal themer information" box displaying the following:

view1

- "container" with settings for the content of view2 which is embedded

Parents:
page.tpl.php
Template called:
views-view--view1.tpl.php
File used:
sites/all/themes/mytheme/views-view--view1.tpl.php
Candidate template files:
views-view--view1.tpl.php

view2

- the list of content along with a pager

Parents:
views-view-row-node.tpl.php < views-view-unformatted.tpl.php < views-view.tpl.php < views-view--view1.tpl.php < page.tpl.php
Template called:
node.tpl.php
File used:
sites/all/themes/mytheme/node-view-view2.tpl.php
Candidate template files:
node-view-view2.tpl.php < node-content_type_specific_template.tpl.php < node.tpl.php

As you can see "Template called" is not the same as "File used" for view2.
Feels wrong and I don't understand why it uses page.tpl.php when the content displayed obviously was rendered by sites/all/themes/mytheme/node-view-view2.tpl.php. But it works and everything else seems to be in order to me. I suspect that when it bugs "File used" is page.tpl.php.
I will get back when I see the error and post the same stuff as above again and see waht is different.

But maybe you see the problem already?

Mattias Holmqvist’s picture

Version: 6.x-2.1 » 6.x-2.0-rc1
Priority: Normal » Minor
Status: Active » Fixed

Hopefully fixed.
Haven't seen the bug appear yet after updgrading views and some other modules to the latest versions.
Tried to upgrade earlier but some cck stuff stopped working so I had to revert.
But CCK 2.1 came out today and everything works after upgrading views as well.

kiteglinton’s picture

Version: 6.x-2.0-rc1 » 6.x-2.1
Component: page displays » block displays
Status: Fixed » Active

I love using views with Drupal 6.6 however I've run into this same snag. I can't get the registry to find any substituted views tpl files except views-view.tpl.php
If I put an adjusted version of this file in my template directory it is found ok. However my view is a block and so to be more specific I've tried putting views-view-block.tpl.php and even views-view-team-block.tpl.php (team being the name of my block containing the view) but neither are picked up in Theme Registry when re-scanned
I've just updated all modules with no change.
Many thanks for any pointers

merlinofchaos’s picture

Ok, I've found this too, and it's a bug in Drupal core. See: http://drupal.org/node/333060

kiteglinton’s picture

Brilliant, thanks m - I did search for it - promise;
Keep up the good work it is really appreciated.

blackdog’s picture

Component: block displays » User interface

Sorry to take this up again, but were on the latest versions of Drupal 6 and Views 2, and while our template files work (i.e. gets used), our problem is that in Views UI, the Theme Information box doesn't see which template file is used, just bolds the default one. Not a really big problem, but kinda frustrating when you got alot of views templates.

I think this issue came up after updating Drupal from 6.6 to 6.7 and 6.8, but I can't be sure.

merlinofchaos’s picture

It's currently a known issue that if your admin theme and your default theme are not the same, the theme: information text is wrong (as it's looking at the current theme which is different). Is this the case on your site?

aangel’s picture

I'm able to confirm this behavior (missing the template files) when the admin theme and default theme are different. When they are the same the rescan picks up the proper template name. I thought at first it wasn't catching templates in subfolders (which is why I came looking here), but that is working fine.

Draggan@drupal.org’s picture

Version: 6.x-2.1 » 6.x-2.2

I'm able to confirm this behavior (missing the template files) when the admin theme and default theme are different, too.

blackdog’s picture

Yes, confirmed as well. Where would one look to try to fix this?

Draggan@drupal.org’s picture

i just found out that rescanning templates (via views2/information) with my own theme suddenly works when using the template.php from garland *wonders*

GuillaumeDuveau’s picture

It's currently a known issue that if your admin theme and your default theme are not the same, the theme: information text is wrong

Ouch ! I've been fighting with this for 2 hours ! Maybe this can be put somewhere in help/views/using-theme while the bug is still present ?

ccshannon’s picture

I'm having a similar problem and I wonder if it's related.

I'm using Drupal 6.9 and Views 2.2

I did notice the issue with the admin vs. production theme, but for testing purposes I made both themes "bluemarine".

I created a tpl.php file for a single field in my View, which is a Grid layout using Field Rows.

Views sees my template file, and when I pass an argument to the Preview form and submit it, I get the results I'm looking for! Huzzah!

But go to the URL for my View page, and the changes are not reflected. No matter if I Empty Cache or Clear Views Cache, I cannot get the View to change appearance.

I went to the View page with Theme Developer enabled, and clicked on the field I'm overriding, but the Theme Developer Information doesn't show my file.

So, does that mean this is a Drupal core bug, and nothing to do with Views? Just checking, as this makes it impossible for me to theme my site output without resorting to overriding theme functions, which I didn't really want to do.

Thanks!

ccshannon’s picture

Okay, just noting please ignore my post. It is NOT related to the problem in the original post. Theme Information suggested:

views-view-field--taxonomy-term--default--tid.tpl.php

and what I needed was/is:

views-view-field--taxonomy-term--tid.tpl.php

without the 'default' display name. Removing '--default' from the filename fixed my issue. Yay!

fm’s picture

It's currently a known issue that if your admin theme and your default theme are not the same, the theme: information text is wrong

Ouch ! I've been fighting with this for 2 hours ! Maybe this can be put somewhere in help/views/using-theme while the bug is still present ?

This turned out to be the solution to my configuration difficulty. My views template wouldn't register until I turned off the administration theme.

jrabeemer’s picture

Title: View not always finding its template file » Views UI won't find template files if admin theme and default theme are different
Version: 6.x-2.2 » 6.x-2.x-dev
Category: support » bug
Priority: Minor » Normal

I run into this problem. I'm using RootCandy and Administration Theme module to make my admin pretty. But, the rescan template button fails with no indication of the new template file being present - no doubt due to the different admin theme. The front-end theme detects and executes the views template however. This is a bug in the UI for sure.

Rebasing bug.

mcrittenden’s picture

Same here. Not really a big deal as templating still works just fine, but it did cause me a few minutes of confusion.

mcrittenden’s picture

Still an issue after #333060: Parent theme pattern clobbering was committed a few months ago.

merlinofchaos’s picture

Status: Active » Fixed

Template file registration is handled by the Drupal core theming system, not Views itself.

Views 2.6 has a theme select so you can specify what theme you're looking at. Rescan does a hard clear of the registry cache. Any further problems are not within Views.

mcrittenden’s picture

Thanks! :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Francewhoa’s picture

Subscribing

mcrittenden’s picture

@Onopoc: don't think there's much use in subscribing now that the issue's been closed for months. Are you still having problems? If so, your best bet is posting a new issue.

Francewhoa’s picture

@mcrittenden: Thanks for asking. Yes I'm having the same issue. I'm trying above solutions but so far none worked. I'm not done yet trying all above solutions though. That's why I subscribed. So I'll continue later. In this case the subscribe is like a bookmark for the lazy bum in me ;)

I'll post my result here when I'm done trying all above solutions. And open another issue if appropriate.

prusso’s picture

Version: 6.x-2.x-dev » 6.x-2.7
Priority: Normal » Critical
Status: Closed (fixed) » Needs work

I have skimmed over everyone's solution and nothing works. I have two completely separate Drupal installs. Both sites need custom view templates to get the correct display. One of the sites it is literally the last thing I need. On both sites I have the Admin Module installed, I have already tried uninstalling the module completely and changing it to my main theme and I get nothing.

In one instance I have the Admin Theme (Module) installed, and when I go to the view it will not see the new template. From there I rescan template files it recognizes the file and I hit "Ok" and then save. It works perfect in the preview but as soon as I go to the live site it does not work. I go back to the theme information and it doesn't recognize the theme template anymore.

When I change the Admin theme to Garland or the default theme it recognizes the template right away but it still does not seem to be saving the template at all. So I am kinda at a complete loss on what to do. Also, I am clearing the cache every time.

Any ideas?

dawehner’s picture

Its not "saving" the template. Views does not do something special here, it just uses the core theme system.

You can select the theme, from which should be scanned, did you tryed this out?

prusso’s picture

In both instances it is already selecting the theme I want to use and want to scan from. I kinda figured it was not actually saving the template file. I have read over this thread a few times and I cannot figure out why it does not work. I have tried changing the file name using different ones and nothing seems to work.

I know towards the beginning they say if you are running a separate Admin theme than the Default theme it does not work but I already did all the work arounds for that as previously stated. Again it works fine in preview but it won't save it so its not applying it to the site. The really odd thing is in the instance where i disabled the admin theme, the template did not even work in the preview.

On one of the sites this is the process I am trying to complete:

http://drupal.org/node/388140

The other site I am simply just trying to get a custom output of the fields, nothing out of the ordinary. Thanks for the input.

merlinofchaos’s picture

Status: Needs work » Fixed

The selection widget on this page does not 'save' anything. You do not choose the theme you want to scan from. The theme system will always pull from the current theme, whatever that happens to be. The selector widget allows you to see what choices will be made, assuming the selected theme is what in use.

That is why the button says "OK" and not "Save". It does not save anything.

You must place your templates in the correct theme. While it's hard to tell because you do not give details about what you have tried (which, by the way, is a nono when trying to get support; precision matters) it sounds like you're placing your templates in the admin theme, which is not the theme that is in use during normal operation.

prusso’s picture

Sorry, I should have been more specific.

This is my process:

I have a custom theme I have created and installed, works fine. From there I have created the necessary content types and views. Currently I have the Admin theme module installed. I have tried with and without this installed. I have also tried using Garland as the admin theme and my default theme as well.

In the example of the grouping of months in a year view. I have the view outputting all my events for the current year. I have done exactly what that they said to do on the walkthrough on this page:

http://drupal.org/node/388140

I created the new views template as specified, I put in the code to rewrite the output of the months so it will group by month. This is all being placed inside the custom theme I created, not the admin theme. However someone suggested that you have to do that to get it to show up (that still did not work). From there, I go to my View then to the Year view and then to Theme information. Right away it does not recognize the new custom view template that I created. So I click "rescan template files" and it will bold the new template file I uploaded. I click "Ok" and then Save the view. I check hte preview and it works great. I have tried this process with and without clearing the views cache. Both times when I go to the page to view it, it does not seem to be working. I then go back to the View I just edited and the custom view template is no longer bold.

I have also included two screenshots of the preview output and the live view. Extra note: the screenshot of the view preview is not styled but it is working.

The other instance I have is the same issue where I have a custom theme, and a custom view template that I get the exact same result. With this one I am purely just trying to customize the field output, nothing fancy.

Thanks for the help I hope this makes more sense.

*** Minor Update

I went back and changed my admin theme to my new custom theme. I go to the Views and the Theme Info and it sees the custom template right away. However this time when I go to preview it does not work. So for some reason the preview works how it should with the Admin on Slate but when it is on my custom theme it does not. Trying to debug my template file.

prusso’s picture

Status: Fixed » Needs work

I got the first issue regarding this post: http://drupal.org/node/388140

We were referencing the value of the node's value structure incorrectly. Specifically this code snippet:

print date('F Y', strtotime($row->node_data_field_date_field_date_value));

Once we printed out the raw data we got the correct value. I also agree with everyone that it seems as though the Admin Module is causing these problems. When the theme is not set to your Default theme ( the live theme) it seems to be conflicting. I still am not 100% sure this is causing the problem. I am going to try to fix the other custom view template I was writing for the other site with that chance of themes to see if it works.

As far as I can tell I sitll believe that you have to have your Default theme be the same as your Admin theme to get it to recognize and rescan the template files properly. I will keep updating this as I go along.

merlinofchaos’s picture

Status: Needs work » Active

'needs work' indicates there is a patch.

It is possible that admin theme is messing with Views' ability to actually look at which theme is in use. I will comment that 'rescan' doesn't actually do much; it clears the the theme registry and allows Drupal to rebuild the theme registry through its normal process. Views actually does not participate in this process, other than advertising what theme hooks it uses.

When it is displaying the template that will be in use, it is taking this information directly from the theme registry and poking through it to see which if the possibilities are registered. The 'first' registered possibility is the one that gets used, though they're displayed in reverse order.

It is very strange that it seems that your theme template will be registered, and then later not registered. I don't have any good ideas why that might happen, but I will note that Views does not actually participate in that part of the process.

prusso’s picture

Sorry about the mix up on the status, not used to all that.

I have not had a chance to check the other site to see if the Admin theme is the cause. Thanks again for the help and notes.

greg.harvey’s picture

I've never had any trouble like this, but I would note D6 theming (particularly saving of default and enabled themes, and their related settings) seems to have a few unresolved issues in core. It could be you're seeing the result of this?

For example, I've noticed in the past that Drupal 6 (still, even with latest core) sometimes "forgets" which themes are enabled. Try looking at your list of themes and seeing if they still have the "enabled" box checked. It could be that something like this is tripping you over, but that would be nothing to do with Views.

Just a thought... =)

prusso’s picture

So just a note about the whole Admin theme issue. I got the custom template working on the live site and I went back and changed the theme to Slate or Admin from the Admin Module and everything still works. So I guess it might have just been my incorrect value. I am still working out stuff on the other site so we shall see.

Thanks agian.

prusso’s picture

So as far as I can tell everything seems to be working with the Admin Module.

I have replaced two template files and it is all working fine. The only odd thing is that when you go back it does not show the template files as highlighted till you rescan for them.

Here is the process:

I have the Admin Module installed. I select the specific template file I need to be over writing and I replace the appropriate code. I go into the themeing information and none of the template files are recognized at first. I hit rescan template files and both become highlighted. After that I hit ok and then save. Go to my page and everything is working. At no point did I clear the cache at all.

I did just check to see if clearing the views cache would mess it up and everything is still working.

So as far as I can tell Admin module does not conflict with the Views custom templates. The only odd thing it does not do is recognize template files before hitting rescan and after you have saved.

Hope that helps, thanks again for all the help as well.

bigknot33’s picture

#17 fixed my issue. Thanks :).

Theme Information suggested:

views-view-field--taxonomy-term--default--tid.tpl.php

and what I needed was/is:

views-view-field--taxonomy-term--tid.tpl.php

without the 'default' display name. Removing '--default' from the filename fixed my issue. Yay!

merlinofchaos’s picture

Status: Active » Fixed

Quick note on #39: That 'default' will only apply to the default display, and not other displays. The default display is only used for embeds; page or block displays would be used for others. Hope that helps explain what happened there.

Francewhoa’s picture

In my comment #27 I said I would try all above solutions then post my result. Here it is. Nothing worked.
But I found a workaround. The module http://drupal.org/project/role_theme_switcher This module is able to set different admin theme and default theme. And this can be for different roles including anonymous role. And it works fine with Views.

About my setup.

  • Drupal 6.14
  • Drupal multisite fresh install
  • Views 6.x-2.6
  • Ubuntu Server Edition 8.04.x
  • Admin theme: Garland
  • Default theme tested: Zen, Marvin or Pushbutton
saltcod’s picture

I was having the same issue. I had the right template filename, but it would not get 'picked up'.

I originally had page-[ViewName].tpl.php stored in a /templates folder in my theme. When I moved the tpl.php file into the main folder things worked fine.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kirikintha’s picture

Issue tags: +views 2, +Admin Module, +Fusion Theme

Hi everyone - I did run into this same problem with re-scan views template, using a sub theme of the base theme fusion, and the admin module from development seed.

Drupal 6.15
Views 6.x-2.8
Admin 6.x-1.0-beta3
Skinr 6.x-1.1
Fusion 6.x-1.0-beta3

When using the Admin module as the admin theme (system default), and I am updating the template for a particular view, re-scanning the template does work properly (you see the nice change in bold!), until you save the view. Then, when you review (no pun intended, but a good one never-the-less) the view, it only shows the default, template settings - no changes are visible in the template, or theme. Also, using the admin module trashed any other views template settings I had in any view. In short, using views templates (those awesome .tpl files) and the admin module with a subtheme, is not a great option yet. The admin module (as of this post) just doesn't seem to play well with Drupal admin yet. Development Seed is on the case, and I believe they are working on an admin 2.0.

So, just for clarification and pointing out the obvious (I'm sure), but the admin module, and Fusion are both in beta, so not-so-much in production development environments without thorough testing first! I've also noticed a ton of js issues across browsers, but that's another story entirely.

Long Story short, I believe one can use the admin module for end-users, but not developers yet. I switched back to Garland, Push Button, and Chameleon, and have not had any issue with views (any version). This seems to be the only solution right now.

Thanks for reading!

-k

Andric Villanueva’s picture

kirikintha, I'm having the same issues now a month later.

It'll scan just fine but it won't save. As a matter of fact if you press okay and click theme information again it'll all be the default template files. I think that this has to do with another module other than admin because I don't have that installed.

Drupal: v6.15
Views : v6.x-2.8

I'm uninstalling every other module until I find this.

Cheers,
A.Villanueva

timdp’s picture

Title: Views UI won't find template files if admin theme and default theme are different » Views UI won't find template files
Version: 6.x-2.7 » 6.x-2.8
Priority: Critical » Normal
Status: Closed (fixed) » Active
dawehner’s picture

Can you please also report your theme structure:
1) do you have a subtheme?
2) do you have a theme which had the basic tpl also in the theme dir.

merlinofchaos’s picture

Please let me stress that Views is not what looks for your template files. This is a Drupal core feature that Views leverages. Every time someone says that Views cannot find their template files, I cringe. Views does not do this, Drupal core does.

At this point, without having some access to a server where this is happening that allows me to debug the actual flow of finding the template files, I really have no idea why this is happening, how to reproduce it, or how to fix it.

esmerel’s picture

Status: Active » Postponed (maintainer needs more info)
kirikintha’s picture

MOC is totally correct, I am back-linking my post - http://drupal.org/node/653142 in admin theme, to let everyone know in my case, this is not a views problem. Just an FYI to help everyone else trying to debug this problem!

Thanks Merlin - you're efforts are always appreciated!

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Not a views issue.

subadmin’s picture

i have a problem in view attached file
any body have solution please tell here.

Regards
Awais