Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.6
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Jan 2009 at 17:10 UTC
Updated:
15 Dec 2009 at 15:28 UTC
I've created a custom template file for displaying a table (views-view-table-altered.tpl.php). However I found I cannot simply place it in the views/themes folder and see it when i click "information" next to "theme:" in the views edit pane. How would I tell views to use this custom template other then simply replacing the default table template. Thanks!
Comments
Comment #1
merlinofchaos commentedThis is explained in the advanced help topic "Using Views templates" that comes with Views.
Comment #2
clarkwolfe commentedIt seems like it just doesn't see my custom template, despite being named correctly. :-(
I have created a template named more specifically then the default template file as shown in the "theme: information" area. The file is called "views-view-table--user-list.tpl.php" and is in modules/views/themes/ folder. I know this is the right folder because when I delete the default table template and press rescan template files it complains that it can't find the default template, but seems to ignore my template even though it is named correctly. Am I doing something wrong? I have cleared the cache and followed all the advanced help instructions.
Comment #3
merlinofchaos commentedI'm sorry, I don't help people who refuse to read the documentation.
If you don't understand how to use Drupal's theming and template features, you need to read the theming documentation.
Comment #4
clarkwolfe commentedThanks for the help... that you say you don't provide, works now. I'll be out of your hair.
Comment #6
suthy commentedOk so I've read a ton of documentation and cannot for the life of me find a way to use a template with a 100% custom name, regardless of the view name. Basically I have 2 views, each with multiple displays. I've created all the necessary templates for the first view and they are working correctly since they follow the standard template name structure. I want to use the exact same templates for my second view, without having to duplicate all the templates and rename them to match the 2nd view name. I've tried doing the following:
My dsm() gives my the template I said to use. But when I clear caches or rescan templates, the view doesn't use it or recognize it in Theme Information.
I've used theme_render_template before successfully in other preprocess functions, but never in a preprocess_views_view_etc. function. Since the views preprocess functions don't use "return", I don't know if there's another way to call a custom template.
Is there any way to call a specific .tpl.php for a view?
Comment #7
suthy commentedThis is a pretty urgent issue. Is there really no way to reuse views templates or call templates with whatever name you want? If anyone has input it would be much appreciated.
Comment #8
dawehnerMh, the code looks fine, i guess, you are missed to clear the theme registry cache.
Comment #9
suthy commentedI've cleared all caches, specifically the theme registry cache several times.. it just won't use a tpl.php that i declare. This doesn't make sense. I was able to force templates in Drupal 5 just fine. Why would this ability drop?
In D5 I would just toss this in the end of my function theme_views_view_list_name_of_view($view, $nodes, $type) ...
and it would use name_of_view.tpl.php or whatever I wanted. Something simple must not be working correctly. I would assume I'd be allowed to do something similar with theme_render_template() but it doesn't seem to be the case.
Anyone? merlinofchaos?
Comment #10
suthy commentedGOT IT!
http://drupal.org/node/223440
"Suggestions work only when it is placed in the same directory as the base template. Templates can be placed in any sub-directory of the theme. They must be paired into the same location."
We didn't have a views-view.tpl.php in our theme directory. Once I did that, BAM! worked. Knew it was something trivial.