6

So far, I've been able to put page, node, field and block templates in their own separate folders. My idea is that Drupal needs to find the main original tpl file (ie page.tpl.php) in a folder and will then look for the overriding files in that directory. If so, how do I structure a similar thing for my Views templates? Do I create a few folders and put the original files (view-fields.tpl.php etc) in each respective folder?

I'll try my own suggestion and will post back if it works, so that others can benefit from it.

  • 2
    Apparently I need more karma just to vote up a good answer, so now I get to post a useless extra answer just to say: beeradb's answer is a good one. – laura Mar 26 '11 at 17:49
11

I typically put all TPL's in a templates folder, further subdivided by categories such as views, node, page, etc.

Here's an example folder structure from one of my recent projects:

themename 
- fonts
- images
- scripts
- styles
- templates
-- node
-- page
-- user
-- views

Basically, the only thing that goes into the root folder is the .info file, and the template.php file. Everything else is subdivided by category.

| improve this answer | |
1

I put all my Views template files in the same folder. However you can separate them if you want. Your approach will work. Principle: if you override a template, you must override the base file, too, and put them in the same folder.

| improve this answer | |
1

Drupal will search everything under your theme's root (the folder with the .info and template.php file) folder. Therefore your folder structure can be whatever you like, drupal will simply recursively scan your theme folder until it finds the template file its looking for. The Zen theme and its sub-themes have a nice folder structure as a starting point.

I would suggest:

themename
-fonts
-images
-js
-templates
-css
themename.info
templates.php

It comes down to personal preference in the end, as long as its structured and another theme developer could step in and find things its all good!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy