Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

The Eclipse, PDT and Smarty dance Code and Hacks

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


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


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.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.

What is the primary language of this blog? (Anti-SPAM question)

Submitted comments will be subject to moderation before being displayed.