Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems
Code and Hacks

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

Install Steps

  1. 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.
  2. 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.
  3. 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
  4. 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 :
    1. Shut down Eclipse
    2. 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
       
    3. Start eclipse with -clean parameter, eg: /path/to/eclipse -clean
    4. Should work now

Other issues

While I probably should have stayed with Galileo, I updated to Eclipse Helios as I thought that the newer PDT 2.2 will have better Smarty support. It did not, instead it had a diff bug - if you compare PHP files you get an empty diff window. Following the suggestions of the bug above I used the "milestone" update site and that fixed the diff issue, but of course I had to repeat the Smarty hackery above

Update

Eclipse Indigo appears not to need any of this hackery - install eclipse, install PDT (from the predefined update site), install SmartyPDT as a local archive (as above), done. (You may need to run it using eclipse -clean after installation)

0 Trackbacks

  1. No Trackbacks

0 Comments

Display comments as (Linear | Threaded)
  1. No comments

Add Comment


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
Markdown format allowed


Submitted comments will be subject to moderation before being displayed.