I had this all figured out with Drupal 5.x, but now I'm moving over to Drupal 6 and I'm running into some webform problems.
According to #243860: Theming the output in 6.x and THEMING.txt, I should be able to override the default files webform-confirmation.tpl.php, webform-form.tpl.php and webform-mail.tpl.php by placing them in my site's theme folder and editing them as needed. Doing so means I don't have to add custom code to template.php anymore?
However, I have not been able to override any webform or even a specific webform node (webform-mail-8.tpl.php, for example) unless I place it in the Webform module folder. Placing the custom files in my theme folder, as stated in the documentation, has no effect. Please let me know what I may be doing wrong.
Comments
Comment #1
quicksketchTwo things you'll need to watch out for:
1. You'll need to clear your cache after adding new .tpl.php files to your site's theme. In Drupal 6.2, I know there a few bugs that deal with theme file discovery, the most reliable approach is to visit admin/build/themes and just save the form.
2. If you've upgrade your theme from Drupal 5, you'll need to removed any previous theme_webform_* functions from your template.php file that are now .tpl.php files.
The new theme system in Drupal 6 now handles the discovery of theme files automatically, so if they're working in the webform directory, they should work just as well in your theme directory.
Comment #2
pawpetcare commentedThank you for the reply quicksketch.
I'm not having any luck getting this to work. I even installed Devel so I could use it's 'Empty Cache' feature instead of the built-in functionality.
The custom tpl.php files still only work when placed the the module's directory. An exception is the webform-confirmation.tpl.php file; it works unless you append the node number.
I'm not upgrading any website, I'm using a new installation of Drupal 6.3 and Webforms 6.x-2.1.1 and just playing around to test the new functionality. I've been happily using Drupal 5.7 with Webforms, but put off upgrading until CCK and Views were released for 6.x.
This problem has become a deal-breaker for me to use Drupal 6 right now.
Can you please verify that this does indeed work?
Comment #3
tidalx3 commentedAt least you figured it all out in 5.7. My webform confirmation shows up empty after trying the confirmation tpl method. After following the instructions in theme.txt to a t, nothing happens. Can you provide some tips on how it worked in 5.7? I just need the webform to show the user exactly what they had submitted at the confirmation page. For usability, that is important, but I can't get anywhere after looking at numerous posts.
I think it was because form_values are not passed to the confirmation page? All I got was a tip to extract it from $sid? Any code samples? Or a way to cut and paste something from the sent out email?
Comment #4
pawpetcare commentedI've done some more troubleshooting and have gotten at least the custom confirmation to work, but still not a custom email.
According to #279573: Themes can't use node-story.tpl.php without node.tpl.php, the custom webform nodes will not work without the original ones copied to the theme's folder first. I copied webform-confirmation.tpl.php and webform-mail.tpl.php to my theme's folder (Garland) and the custom confirmation worked as it should. Still a no-go on the custom email. :(
UPDATE: The email cannot be customized even if I edit the default webform-mail.tpl.php template in my theme's folder. So far this is only working if it is placed within the module folder. Again, I'm using Drupal 6.3, so maybe it has something to do with the referenced article?
UPDATE 2: I just made a simple test form in an older Drupal 6.1 localhost install, and the same problem exists there, as well; custom confirmation works, email does not.
Comment #5
quicksketchThanks pawpetcare. Looks like your quite correct. Strange ways that the Drupal 6 theme system works are making this a not very straight-forward task. I committed a few fixes that should at least get theming working, as long as you have a whole "webform-mail.tpl.php" in addition to any node-specific ones. I know Views does some special dynamic templating that we might be able to utilize to get around this problem. I'll look into it and see if we can get this thing working.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/webform/web...
Comment #6
quicksketchEureka! With a little magic pattern matching in the new theme system, Webform can actually have it's template system work the way I expect. I applied a second round of patches on top the changes made in #5 to get everything working like it should. I'll get out a 2.1.2 version to correct this nasty problem.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/webform/web...
Comment #7
pawpetcare commentedQuicksketch, thank you for getting this to work!
Now email templates and confirmations work as expected and there's no need to add the original webform-mail.tpl.php and webform-confirmation.tpl.php to the theme folder.
Comment #8
quicksketchYay! Thanks pawpetcare for your very helpful reports. A good tester can really help speed things up!
Comment #9
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #10
andypostI'm using default version - headers are fine but body is empty (two fields name+email - both marked for emailing)
Comment #11
andypost#317637: Webform 2.2 email content is blank fixed here but not released
Comment #12
quicksketchRight, as andy says, this issue is already fixed and released. It introduced a new problem though, which is fixed (but not yet released) in #317637: Webform 2.2 email content is blank. Follow that issue for information.