Drupal will not load page.tpl.php for one theme. I keep getting page.tpl.php out of modules/system, not the page.tpl.php from the theme. The theme was pure CSS then I needed an extra div so I added page.tpl.php. Drupal keeps using the system page.tpl.php, not the new page.tpl.php in the theme. I tried clearing cache using the admin thing and by emptying the tables. I reset the theme registry the several different ways. The only thing that worked was to disable the theme in the admin list then rename the theme then switch the new theme on. I cannot use that as a method of updating dozens of themes across hundreds of sites. A search of the Drupal code for variations on page.tpl.php does not show where Drupal decides to load the theme page.tpl.php. A search of the database does not show the file registered anywhere. Does anyone know where the Drupal code looks for page.tpl.php in the theme?
The only experiments that worked:
Renaming the directory and .info file: Drupal recognized all of the theme including page.tpl.php.
Some experiments that failed:
Moving the theme to a new directory: Drupal recognized all of the theme except page.tpl.php.
Deleting and reinstalling the theme: Drupal recognized all of the theme except page.tpl.php.
Adding a template.php file: Drupal recognized all of the theme including the template.php file but not page.tpl.php.
The weird stuff gets weirder. The theme has subthemes and the subthemes all get the theme page.tpl.php.
Most of the time Drupal saves huge amounts of web development time but occasionally it drifts off into space like a notebook going into sleep mode. I rarely look at the theme end of Drupal and do not have a clue where the relevant bits of code hide out during daylight. If you can tell me where Drupal does the check for page.tpl.php, I might be able to test from there.
The other weird thing I found is that Drupal is switching off some error reporting prior to loading page.tpl.php. To check for code errors, I performed both a manual load of the code and introduced deliberate errors to see where code reacted. Some of the errors were reported but many of the errors where never reported, indicating a real error reporting problem. There should be an admin option to immediately report every error during development.
Comments
Mmmmmm...
Its not weird, sounds like your jumping ahead of your self. Drupal picks up the page.tpl.php page once the theme with this .tpl file in is selected and used.
Try this: Unselect the offending theme in Admin and switch to Garland or something.
Site Configuration / Performance / Clear cache
Strip the themes .info file right down to it's bear essentials. This page will be the one you want to read over again and double check everything.
http://drupal.org/node/171194
Make sure your markup isnt broken in the page.tpl.php file (if not completely replace the markup with the Garland theme page.tpl.php just for troubleshooting).
Upload if your remoting.
Then Reinstate the theme.
Also, make sure the Admin Theme is set to your theme. I've had problems before with this functionality
Also, If you have "dozens of themes across hundreds of sites" I'm very suprised you cant work this one out, and that I'm not the one asking for your advice?
Oh, PS: Dump your browser cache to, properly, or use a mixture of browser to test the theme.
Tried all that. Still looking for the file detection code.
Hello i-sibbot,
I tried unselecting the theme, using something else, and going back. It did not work. The page.tpl.php was used when I renamed the theme to something else but failed again when I named the theme back to the original name.
Cleared cache several times but it did not make a difference. I also emptied the cache tables in the database but it did not work. I turn caching off when starting theme changes so there is unlikely to be anything in the cache.
The .info file was built one line at a time to get the bare minimum .info file and worked for months before the page.tpl.php was added. There are no changes to the .info file. The .info file points to just one style.css and that file works.
The page.tpl.php file works when I rename the theme, suggesting the page.tpl.php file is clean. I also replaced the page.tpl.php file with the file from another theme and the replacement was ignored. The original and the replacement are both picked up in the subthemes. If the logic for finding page.tpl.php in the current theme is different to the logic for finding page.tpl.php in the parent theme then the difference is the bit that I need to look at.
My experience with themes does not include working through the related Drupal theme code. I did try a couple of times but went round in circles, sort of like going to the library for research but spending all day stuck in the revolving door at the entrance.
The browser cache holds CSS and JS. The page.tpl.php changes the divisions around the page and is visible through both View page source and Firebug. The slightest change to any other page.tpl.php appears instantly, ruling out the browser as the culprit.
I might resort to renaming the theme then creating a subtheme with the original name just to get the theme working.
Another search of the Drupal code shows function phptemplate_theme, in the phptemplate.engine file, looks for .tpl.php files using function drupal_find_theme_templates. drupal_find_theme_templates is in includes/theme.inc. The problem is probably somewhere in that function.
petermoulding.com/web_architect
Its works..
Problem with admin them. I did not change my admin theme. When i changed my admin theme into my custom them now my custom theme page.tpl.php load successfully. Problem solved.
............Thank you
Not sure if this is something
Not sure if this is something you tried... But to reset the theme registry (you often need to do that when adding/modifying files) all you have to do is visit the page /admin/build/themes
I visited the themes page about 20 times
I visited the themes page about 20 times trying various combinations of pages. I also tried deleting the related rows in the system and variables tables. From what I can see, the theme registry is a row in the system table with type set to theme and name set to the internal name of the theme. I could not find a reference to page.tpl.php in any of the themes that successfully use a page.tpl.php file. The page.tpl.php file must be found some other way. I would like to find the code that finds page.tpl.php so I can check the logic in the code.
petermoulding.com/web_architect
*_*
I am sure you haven't tried this yet..
1) Open your db
2) Browse system table.
3) check path/name of the theme in question.
4) Make sure it has proper path in the first column.
Regards.
Regards.
🪷 Beautifulmind
system.filename and paths correct
The file name is correct. All the paths in the info column are correct in the system row. There is no mention of a path to page.tpl.php.
petermoulding.com/web_architect
I found the theme registry row
cache.cid = 'theme_registry:theme_name
petermoulding.com/web_architect
Found a problem
The theme had some subthemes in the same directory. This works for .info, CSS, Javascript, and images. It apparently does not work for page.tpl.php. The theme code appears to allocate the page.tpl.php file to the subthemes, not the main theme. I moved every subtheme to an individual directory and page.tpl.php started working for the main theme. It still works for the subthemes.
Moving the main theme to a subdirectory did not work. Moving all the subthemes to subdirectories and leaving the main theme in the main directory worked. The different results might be due to the sequence the directories are processed.
Renaming the main theme worked but that might be caused by a change to the processing sequence of the files because I actually made a copy into the new name then deleted the original.
The Drupal template processing uses array_merge and array_merge replaces duplicate keys. That might place the page.tpl.php file in a subtheme instead of the main theme when they are in the same directory.
From now on I will put every theme in a separate directory even when they are only CSS.
petermoulding.com/web_architect
Well Done
Are you using 5.x?????
The original link I sent up top has a Sub Theme section which states...
"Drupal 5 and below required sub-themes to be in sub-directories of the parent theme. This is no longer the case"
If your using 6.x then that statement sort of looks stupid, as the structure would appear to be inplace still.
Personally, I'd alwasy create sub folders for sub themes as I try to be tidy! :)
Well done for providing some insight into this weird happening thought!!!!
Using D6
I think in D5 subthemes were always in subdirectories of the parent theme. D6 lets you place the subtheme directory in a separate directory so you can ship a subtheme separate from the parent theme.
Theme example is identified by the example.info file. CSS and Javascript files are named in the .info file which lets you name example.css in the example.info file and put it in the same directory. example can share a directory with demo_theme.info and demo_theme.css. A problem occurs when you have multiple themes in the same directory and one page.tpl.php or, presumably, any other template file. Drupal does not know which theme owns the template file.
I expect the following would still work.
example/example.info
example/example.css
example/page.tpl.php
example/subthemes/example-b.info
example/subthemes/example-b.css
example/subthemes/example-c.info
example/subthemes/example-c.css
example/subthemes/example-d.info
example/subthemes/example-d.css
petermoulding.com/web_architect
Just a quicky, if anyone else
Just a quicky, if anyone else is reading this and has the same "Druapls not using my themes page.tpl.php" I discovered the other day that if you dont specifiy the Theme engine in your themes .info file, Drupal will not use your page.tpl.php but will use everything else, like scripts and css files.... which leads to a bizare feeling of "I'm styling it, and it's changing apperence, but the new markup isnt showing!" :)
I am using the Celju theme
I am using the Celju theme and it won't read my theme template.
No idea what to do. :(
**Figured it out.
The following worked in template.php:
function phptemplate_preprocess_page(&$variables) {
// IF THIS IS NOT WORKING BE SURE TO CLEAR THE THEME REGISTRY.
// FAILURE TO DO SO WILL NOT ALLOW THIS FUNCTION TO BE CALLED.
if($node = menu_get_object()) {
$variables['node'] = $node;
$suggestions = array();
$template_filename = 'page';
$template_filename = $template_filename . '-' . $variables['node']->type;
$suggestions[] = $template_filename;
$variables['template_files'] = $suggestions;
}
}
Took out:
function _phptemplate_variables($hook, $vars) {
switch ($hook) {
case 'page':
// Add page template suggestions based on node type, if we aren't editing the node.
if ($vars['node'] && arg(2) != 'edit') {
$vars['template_files'][] = 'page-nodetype-'. $vars['node']->type;
}
break;
}
return $vars;
}
Thanks this helped me a lot!
@i-sibbot:
Thanks this helped me a lot! I was migrating a theme from 5.x to 6.x and couldn't figure out why it was NOT reading page.tpl.php but WAS reading style.css. Turns out I was missing 'engine = phptemplate' in my .info file. Huge kudos to you for posting this!
No worries
Just pay it back to the forum when you have a gem like that! :)
D5 Themes causes missing theme page.tpl.php
Hi all together,
also i had the problem to access the page.tpl.php of my theme.
Updating from D5 to D6, i had leaved old themes in different subdirectory of /themes.
This causes current theme failure.
After deleting old theme files, everything works fine.
thank to all
markus
Just got bitten by this,
Just got bitten by this, without an 'engine = phptemplate' the subtheme won't use the provided page.tpl.php and defaults to modules/system/page.tpl.php. *sigh*
Worked great
Thanks this worked for me!!! ;-)
Thanks a lot
I have been trying to figure out why D6 would not use page.tpl.php though it was supposed to. Indeed the engine statement was missing from the info file.
Removed subthemes but problem still occurs 10% of the time
I am using the marinelli theme. I have removed the subtheme folders Gnifetti, Giordani, and Alagna. It was working for a while, but recently while editing a node as admin the theme switched to the modules/system/page.tpl.php.
If as admin, I browse to admin/build/themes the proper theme gets loaded.
How is a guest or non-admin user supposed to fix this?
The problem occurs for any role or anonymous user.
Ninety percent of the time the proper theme is loading, but that 10% it will switch the theme to modules/system/page.tpl.php. After it switches, the entire site becomes stuck on the modules/system/page.tpl.php theme.
I am running a multi-site. I cannot replace modules/system/page.tpl.php with one of the proper themes.
What causes Drupal to choose modules/system/page.tpl.php over my theme's page.tpl.php? And why does it only happen some of the time?
This is quite annoying and nearly a show-stopper.
Drupal 6.1.6
Marinelli 6.x-2.96
Was always off or always on for me.
Hello Derby,
Your random switching sounds weird. The problem occurred for me only when I used a certain directory structure. It sounds like a different problem. Here is a theory for your random problem. Your theme information is rebuilt when you visit the theme page. The theme information is used correctly for a while. Some weird error occurs and some theme information is lost. You get the error until the theme is rebuilt. At the time when the error occurs, there might be a log entry of some type. If there is no log entry, you might have to switch on all PHP error and warning displays to see what happens. Next time the error occurs, select Administer » Site configuration » Performance and clear the cache to see if that fixes it.
It could be a timeout when Drupal is reading a theme component. Do you have page timeouts? Lost database connections? Did you install a new module or a major update to a module?
What else? Just guessing here. If you site popularity is growing, something could be choking. Do you have throttling active? Have a look for PHP errors in Apache logs. Is Apache reporting problems? Does your theme have good Feng Shui?
petermoulding.com/web_architect
log entries
These errors come in as PHP type errors. I can only guess it is at this point that any theme I choose, including bluemarine, garland, and pushbutton after these errors the theme switches the generic default page.tpl.php file in modules/system/
The user in the log is the Guest or Anonymous Visitor.
call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'imce_access' was given in /home/derby/drupal6sites/includes/menu.inc on line 452.
include(./sites/domain.name/themes/marinelli/block.tpl.php) [function.include]: failed to open stream: No such file or directory in /home/derby/drupal6sites/includes/theme.inc on line 1020.
include() [function.include]: Failed opening './sites/domain.name/themes/marinelli/block.tpl.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /home/derby/drupal6sites/includes/theme.inc on line 1020.
To get the theme working again I have setup drush on a cronjob to run every 30 min and clear all cache. This is a hack, and I would rather find the problem than treat the symptoms. Also as pointed out above I can as Admin browse to /admin/build/themes.
Am I really the only one with this problem? It could also be relevant that I'm running Multi-site, though only one site is active right now with about 50 visitors per day.
Is this in any way related to your LAMP version?
Is this in any way related to your LAMP version? 'cos i sometimes get similar errors when i test my local drupal installation in my laptop and desktop which runs on different versions of lamp.