Velocity vs Freemarker

Patrick Hisshion, modified 11 Years ago. Junior Member Posts: 29 Join Date: 5/12/14 Recent Posts
Hi All,

I'm new to Liferay development. With themes I notice that when creating a theme in the IDE, by default the template files are all .ftl. However when I download themes online, they all seem to be .vm. This includes alot of templates that are in Liferay itself, not just within the themes.

When creating templates should I create new .ftl or .vm files? Could I also just edit the existing .ftl files in the theme?

Thanks
thumbnail
David H Nebinger, modified 11 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Use whichever templating language you feel comfortable with. Historically Liferay has used mostly velocity, but they use freemarker for the ServiceBuilder scripting and there was (a few years ago) a push to get away from Velocity in favor of FreeMarker, but I think most of the evangelists have moved on to different soap boxes.

No, you do not want to just edit Liferay files. If you need a theme, then do a theme, but don't try to edit their files directly. Trust me, it will seam easy now but it will come back to bite you when you attempt a Liferay upgrade.
Patrick Hisshion, modified 11 Years ago. Junior Member Posts: 29 Join Date: 5/12/14 Recent Posts
Thanks for the response. I was wondering if you could answer a followup question. Say I wanted to edit the portal_normal.ftl. Should I just copy that file into the _diff folder and edit it there?

If I wanted to make new .ftl files, do I create say, example.ftl and include these is various places within portal_normal.ftl?

Cheers!
thumbnail
David H Nebinger, modified 11 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Yes and yes.

All of your changes need to be in the _diff folder. Otherwise, they may get overwritten when the SDK copies in the parent files.

Remember that both the theme and the layout are processed on every single page refresh. You want to make them as light as possible to minimize the performance impact.

So while good programming sense will want you to break up the files into manageable and logical pieces, in the long run this can work against you at runtime.
Patrick Hisshion, modified 11 Years ago. Junior Member Posts: 29 Join Date: 5/12/14 Recent Posts
Thanks again for the informative response.

Remember that both the theme and the layout are processed on every single page refresh. You want to make them as light as possible to minimize the performance impact.


Do you mean I don't have to deploy when I make a change to my .css files? The change will be made automatically?

Also I'm having quite a problem with my css. Currently the way I have done it is, in the _diff folder I have made a custom.css file with an import to test.css. test.css is where I made the majority of my changes. I decided to remove the import to test.css but the css rules from test.css are still being applied to the page! Even after I had redeployed!
thumbnail
David H Nebinger, modified 11 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Patrick Hisshion:
Remember that both the theme and the layout are processed on every single page refresh. You want to make them as light as possible to minimize the performance impact.


Do you mean I don't have to deploy when I make a change to my .css files? The change will be made automatically?

No, it's minimizing the complexity in the theme/layout. Obviously w/ velocity or fm templates you can get pretty fancy. Look at the navigation.vm file, for example. It's looping through the page items to add menu links. This kind of thing is necessary, but you have to remember it's getting processed on every page refresh. If you added more loops, more conditional logic, etc., this adds to your page rendering time.

Also I'm having quite a problem with my css. Currently the way I have done it is, in the _diff folder I have made a custom.css file with an import to test.css. test.css is where I made the majority of my changes. I decided to remove the import to test.css but the css rules from test.css are still being applied to the page! Even after I had redeployed!


You have to remember that the browser may cache your css/js files. Remember to clear your browser's cache during development.
Patrick Hisshion, modified 11 Years ago. Junior Member Posts: 29 Join Date: 5/12/14 Recent Posts
You have to remember that the browser may cache your css/js files. Remember to clear your browser's cache during development.


Unfortunately I don't believe this is the case, as I have already cleared my browser cache, as well as cleaned the tomcat cache.

Yet still I am inherting rules from my test.css file which is now not imported through the custom.css file. So this shouldn't be happening right?