Question

Dotcms does have a nice template system based on velocity, but it seems like it only support editing the velocity templates inline in the browser which kinda sucks. I really like to using Eclipse when writing velocity templates(Got some nice velocity support, and is a far better editor, then the standard browser text control).

Is there any way to edit the dotcms templates from Eclipse and then automatic import them into dotcms. Or do I really have to write them in Eclipse and then copy/paste each template into the browser each time i edit it?

Was it helpful?

Solution

I agree that working in eclipse is way better than working in the browser. That is why I externalise all Velocity code and include those external files in my content. Using webdav you can mount the dotcms website browser to a windows drive letter. This way you can edit the files using other editors. I do it like this:

  1. Create a folder in the dotCMS Website Browser: /vtl
  2. Place all velocity in separate files in that folder: /vtl/filteredProducts.vtl
  3. In the content put a #dotparse instead of tyhe velocity code itself. #dotParse("/vtl/filteredProducts.vtl")
  4. All the files in dotCMS website browsers are available via webdav at the folowing location: http://www.yourdomain.com/webdav/autopub. make sure that the dotCMS user you log in as in webdav has access to those files (you could even create a seperate dotCMS role that only has access to those files and nothing else). Don't use the default windows webdav client because irt doesn't enable you to edit the files on the mounted drive. I use Netdrive, which is free for personal use. I also have heard good things about Gladinet. Install one of these and mount the webdav folder to a drive letter.

Now you can edit the files in eclipse.

There are a few gotcha's:

  1. I have found webdav to be kinda slow, so what I actually do is keep a copy of the files on my local filesystem and edit those using eclipse (also good for svn/git stuff) and synchronise that with the webdav folder. I use Beyond Compare to do the synchronizing. It is not free, but 100% worth its money. No doubt there are free alternatives out there.
  2. Webdav does spooky things when the files get larger: they get scrambled. I don't know why this is, but when files get large this can occur. It has not happened to my vtl files yet, but larger binary files do get mangled now and then.
  3. I believe you don't have to use webdav, but I have not tried it myself. Velocity itself has a #parse function. Maybe you can use that to parse files directly from the server's filesystem itself.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top