Ben
Ben

Reputation: 62404

CakePHP .ctp syntax highlighting in Eclipse

Why CakePHP decided to build their own file format instead of .tpl is beyond me... despite that, i can't get syntax highlighting to work in Eclipse... I've followed this guide: http://planetcakephp.org/aggregator/items/5452-opening-ctp-file-with-syntax-highlight-in-eclipse (dead link) but it doesn't work, I see an error about an unsupported content type for this file. I've added an association to the PHP editor for this file type and it still shows the issue.

Any ideas on how to get syntax highlighting to work?

Upvotes: 19

Views: 11452

Answers (2)

JohnP
JohnP

Reputation: 50019

Make sure you have set the correct editor associations and content types

Go to settings (Window -> preferences)

Content Types

  1. Type in Content Types in the search box (should show under General -> Types
  2. Click on the arrow next to Text, select PHP Content Type
  3. Add *.ctp by clicking on the Add button on the right side

File Association

  1. Type in File Associations in the search box on the left
  2. Add *.ctp (click the Add button on the top right side)
  3. Associate the proper editor for it by clicking Add (on the bottom right side) and selecting PHP Editor

Upvotes: 46

Jondolar
Jondolar

Reputation: 26

You can change the extension that CakePHP uses for view files to an extension that Eclipse likes. In the controller (or app_controller) add the following variable:

var $ext = '.tpl';

If you change the extension to "PHP" you may have problems because CakePHP will try to load a class that matches the filename.

Upvotes: 0

Related Questions