EllisLab text mark
Advanced Search
     
Save template files as .php
Posted: 21 September 2010 11:25 AM   [ Ignore ]
Joined: 2006-06-09
144 posts

How can I save my template files with the extension php? Can I do this in the config file?

 
Posted: 21 September 2010 12:11 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2010-07-03
162 posts

If you are trying to enable PHP within your templates, this must be done through the Control Panel, even if you are editing your templates as files.

CP Home / Template Manager : Edit Preferences (beside desired template)

If you are asking how to change the html extension to php for the templates that are saved to files, I’d have to ask why? Perhaps so that your code editor will use the right text coloring? If that is the case, it may be better (for security reasons) to just customize your editor to treat html files as php.

 
Posted: 21 September 2010 12:24 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2006-06-09
144 posts

Hi hd,

Thank you for your reply. It is the latter.

I am placing my template files above root. So a .php extension could pose no threat I believe.

I am using Dreamweaver as an editor. The thought of customizing the editor did cross my mind mad  I hope that is possible, because it seems that saving the template files as .php might not be a possibility.

 
Posted: 22 September 2010 02:39 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2004-03-22
12298 posts

The Spotlight Kid,

You are correct in your assumption that you will not be able to save template files with the ,php extension.

For the moment customizing DW is the way to go here. Or using a text editor where you can choose the syntax for a file regardless of its extension like e-editor if on a PC

 Signature 

John Henry’s Website | Follow me on Twitter

 
Posted: 22 September 2010 04:10 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2006-06-09
144 posts

Ok, thanks.

For anyone stumbling on the same issue, this is how to get DW to display PHP syntax highlighting in HTML files.

Find MMDocumentTypes.xml in your configuration folder.
Make a backup for caution (save it in a different location to prevent DW from loading the backup on restart)
Change the permission of MMDocumentTypes.xml to writable.
Open the file (I opened it with DW but it might be better to use a simple text editor)
Find the line beginning with <documenttype id=“PHP_MySQL” ...
Add the extension “html” twice
Find the line beginning with <documenttype id=“HTML” ...
Remove the extension “html” twice
Save and close the file
Change the permission of MMDocumentTypes.xml back to read only.
Restart DW

Any html file opened from now on will show you the PHP syntax highlighting.

 
Posted: 22 September 2010 03:46 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
29075 posts

Thank you for sharing your solution with us. Please post again as needed.