The Eclipse, PDT and Smarty dance
Posted by Admin • Monday, January 24. 2011 • Category: Code and Hacks
Eclipse is a great developer tool, and I use mine for Java, PHP, and C++. It actually does all of the above really well, but when it comes to Smarty template Syntax Highlighting, it's a tale of much suffering. I honestly am not even asking for any Smarty auto-completion - just pretty colors that tell me when I'm fat-fingering the syntax.
Fortunately there is a solution that appears to work, and here is the currently valid step-by-step
Fortunately there is a solution that appears to work, and here is the currently valid step-by-step
Install Steps
- In your Eclipse, install PDT using "Help : Install New Software" if you haven't already. This is pretty well documented so I won't discuss that too much.
- Install the Smarty PDT plugin. There seems to be no update site for this plugin, you just have to download the jar and install it using the "Archive" button of the "add site" dialog in Eclipse. There is a trick to installing it: once you select the zip file as the update site, you have to uncheck "Group Items By Category" checkbox.
- Let Eclipse restart and see if your smarty templates look nice. If you have an older (2.0.x) PDT then you may not need to do any hackery, it may be working
- If you have partial highlighting (HTML sections but not smarty), then you'll need to remove the tpl file associations from the PDT core plugin, as that plugin claims them and they are locked, meaning that the new Smarty plugin cannot claim them. You cannot (currently) do this from Preferences - you have to modify the plugin.xml file yourself :
- Shut down Eclipse
- Unzip the PDT core plugin from the plugins dir of your Eclipse installation (which may be .eclipse/plugins or /install/path/eclipse/plugins). I do it like this (Linux):
cd PLUGIN DIRECTORY
mkdir temp
cd temp
unzip ../org.eclipse.php.core_2.2.1.v20101001-2300.jar # This is my version at this time.
edit plugin.xml # search for "tpl", remove tpl from the list of extensions, eg: file-extensions =" php, php3, php4, php5, phtml, inc, phps, tpl"
jar cvf ../org.eclipse.php.core_2.2.1.v20101001-2300.jar * #You may want to back this up first
- Start eclipse with -clean parameter, eg: /path/to/eclipse -clean
- Should work now
0 Comments
Add Comment