Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Modify SubEthaEdit's mode/file extension mappings Apps
Here's a bit of an obscure hint to change which SubEthaEdit "modes" respond to which extensions. I sometimes use php code inside of .html files (rather than use the files with the .php extension; don't ask why), and I use SubEthaEdit to edit the .html files. I wanted to make SubEthaEdit open .html files with the PHP-HTML mode instead of HTML. Here's how...

In the Finder, control-click on SubEthaEdit and select Show Package Contents. Then navigate to Contents -> Resources -> Modes. Select the mode you want to alter, and again control-click and select Show Package Contents. Then open the Info.plist file inside the package.

Alter the TCMModeExtensions property to your liking. Be sure to change the HTML mode appropriately to avoid undefined behavior. Hope this helps someone.

[robg adds: I haven't tested this one, and you'll probably want to backup your SubEthaEdit app before you modify its contents.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[5,873 views]  

Modify SubEthaEdit's mode/file extension mappings | 5 comments | Create New Account
Click here to return to the 'Modify SubEthaEdit's mode/file extension mappings' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Modify SubEthaEdit's mode/file extension mappings
Authored by: seven5 on Jun 10, '04 11:29:03AM

i know you said not to ask why, but what about how? How the heck does your server parse the php, if its got .html on the extension? Did you tell it try to parse html as well? and if so, isn't that a bit inefficient?



[ Reply to This | # ]
Modify SubEthaEdit's mode/file extension mappings
Authored by: taran on Jun 10, '04 02:32:14PM
He could specify .html files to be handled by PHP within a specific virtual host or even only within a specific directory. I doubt that he's having all .html's server-wide handled by PHP. I've done this myself in the past for a couple of reasons:
  1. At the time I prefered seeing .html in the address bar - now I understand that the "average" computer user couldn't distinguish the address bar from Adam.
  2. Most forms I create have two PHP scripts - the form and the script that the form posts to - I use .phtml for scripts that build HTML pages and .php for scripts that only perform actions and pass the browser on to another page.


[ Reply to This | # ]
Modify SubEthaEdit's mode/file extension mappings
Authored by: bih on Jun 10, '04 09:29:37PM

On a per directory basis you can use .htaccess files and specify: "AddType application/x-httpd-php .html"

Yea, it would be a bit inefficient to parse all .html files for php code. I did it in a directory where I have forms and I have a weird naming obsession like 'form.html' for the form content and 'form.php' for the form processing.



[ Reply to This | # ]
Modify SubEthaEdit's mode/file extension mappings
Authored by: Thom on Jun 12, '04 03:43:57AM

Why the heck wouldn't you write a PHP page that both creates the form, and validates it as well? (e.g. posts it back to itself for error checking and submission.) That way, you've got the ability to re-generate the same form, filled out exactly the same way as the user filled it in a moment ago, except perhaps with red text on the column name where they failed validation, etc.

As far as the other suffix conventions -- I use .inc files for libraries of PHP code that are only to be included, never to be parsed as pages themselves, and I have a rule that prevents Apache from ever serving these pages directly. But other than .php, .php3 for legacy compatibility, or .html when I want to be sneaky... that's all I need, anyway.



[ Reply to This | # ]
Modify SubEthaEdit's mode/file extension mappings
Authored by: percy on Jun 10, '04 12:07:28PM

Another, possibly better, way is to copy the mode you're interested in modifying and put it in "~/Library/Application Support/SubEthaEdit/Modes". That way, you won't have to worry about messing something up, and your changes will remain if you were to replace the SubEthaEdit application.



[ Reply to This | # ]