Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sasi Test
using custom velocity properties in the theme
August 2, 2012 12:55 PM
Answer

Sasi Test

Rank: New Member

Posts: 18

Join Date: August 2, 2012

Recent Posts

hi,

We have created a custom theme in our liferay project (liferay 6.1 on jboss 7.1) and we are trying to access additional velocity files from the file system. We would like the out-of-the-box liferay engine to be able to use a fieResourceLoader (and we have a custom velocity servlet). How would we be able to customize(update) the velocity engine with what our velocity engine(properties)?

In the init_custom.vm file we have references to our file:
#parse("/cmsRepository//sessionVariableSetup.vm")

the /cmsRepository would be found in the file path given.

Thanks,
Sasipriya
Dhrutika Vyas
RE: using custom velocity properties in the theme
August 6, 2012 5:27 AM
Answer

Dhrutika Vyas

Rank: Expert

Posts: 435

Join Date: February 9, 2009

Recent Posts

Hi,

To parse in any new velocity file in theme ,

First ,you need to place that file under : ../your-theme/docroot/_diffs/templates

To parse that file you need to write '#parse ("$full_templates_path/sessionVariableSetup.vm") at the place where you need to parse that file.

Regards,
Dhrutika
Sasi Test
RE: using custom velocity properties in the theme
August 6, 2012 8:17 AM
Answer

Sasi Test

Rank: New Member

Posts: 18

Join Date: August 2, 2012

Recent Posts

hi,

I understand how to do that - however, I would like to pull my velocity files from a different velocity loader(file system loader) that I can control vial a cms system. (There might be one or two out of the box templates in the location you described, but I want as much as possible in a CMS system so I can change quickly without a release.).

Hence, I was looking for a way to enhance the velocity engine used by liferay to use a file loader. (I see portal.properties can be used to do this, however, I am not seeing a file listener example provided).. Any help from liferay would be really appreciated.

Thanks,
Sasipriya
Jay Patel
RE: using custom velocity properties in the theme
August 6, 2012 8:43 AM
Answer

Jay Patel

Rank: Regular Member

Posts: 116

Join Date: February 23, 2010

Recent Posts

So are you suggesting that your custom theme's velocity files will not be placed under "/your-theme/docroot/_diffs/templates" & you want to load this from other file system path? If that is the case, then I am not able to understand the objective. Because even though you control it through some other CMS, it won't take effect in Portal unless you again hot deploy it.
Sasi Test
RE: using custom velocity properties in the theme
August 6, 2012 9:05 AM
Answer

Sasi Test

Rank: New Member

Posts: 18

Join Date: August 2, 2012

Recent Posts

yes that is exactly what I am suggesting. Any changes would get picked up by velocity if you set the settings correctly, to pick up new templates on change. Since the file is in the file system, there would be no need for a deploy - we just push the file through CMS, and velocity recognizes that the file has changed and would automatically pick it up.

Thanks,
Sasipriya
Dhrutika Vyas
RE: using custom velocity properties in the theme
August 6, 2012 11:41 PM
Answer

Dhrutika Vyas

Rank: Expert

Posts: 435

Join Date: February 9, 2009

Recent Posts

Hi Sasi,

If you load your velocity files from file system,how would it take directly?

Any way you need to deploy your theme,to get changes. So what will be the advantage of using this way?

Regards,
Dhrutika
Jay Patel
RE: using custom velocity properties in the theme
August 7, 2012 7:11 AM
Answer

Jay Patel

Rank: Regular Member

Posts: 116

Join Date: February 23, 2010

Recent Posts

Well I have my doubts over this. AFAIK, even though you try to load it using File System path what matters is to register your changes with Tomcat. Since theme is deployed as a webapp itself, it must be registered with Tomcat for any changes, so in simple terms it should be hot deployed. Still DO post result of your work in this post, it will be good to know outcome of your effort.
Sasi Test
RE: using custom velocity properties in the theme
August 7, 2012 4:52 PM
Answer

Sasi Test

Rank: New Member

Posts: 18

Join Date: August 2, 2012

Recent Posts

hi,

Well, seems like this is possible, after doing a lot of reading it looks like I would need to add a new VelocityResourceListener implementation class and add it to the portal.properties file via an ext-plugin project. As far as the doubt if it is possible to do the reading of file via a file system, we have the exact same scheme described implemented and working in our production system on weblogic portal for the past 3 years, so I dont see why it should not be possible in liferay.

I did look at liferay ext-plugin documentation and it seems a bit complicated, though that seems to be only way to go forward. Can anyone confirm that I would be able to do a VelocityResourceListener class and add it to the portal.properties via an ext plugin?

Thanks,
Sasipriya
Jay Patel
RE: using custom velocity properties in the theme
August 8, 2012 12:39 PM
Answer

Jay Patel

Rank: Regular Member

Posts: 116

Join Date: February 23, 2010

Recent Posts

Cool, keep us posted if you are successful, it will be nice to know.
Sasi Test
RE: using custom velocity properties in the theme
August 9, 2012 11:51 AM
Answer

Sasi Test

Rank: New Member

Posts: 18

Join Date: August 2, 2012

Recent Posts

this worked. Thank you all for the help.
Dhrutika Vyas
RE: using custom velocity properties in the theme
August 10, 2012 2:44 AM
Answer

Dhrutika Vyas

Rank: Expert

Posts: 435

Join Date: February 9, 2009

Recent Posts

Hi Sasi,

Can you please share with community how you have implemented this? It will be helpful.

Regards,
Dhrutika
Sasi Test
RE: using custom velocity properties in the theme
August 10, 2012 8:27 AM
Answer

Sasi Test

Rank: New Member

Posts: 18

Join Date: August 2, 2012

Recent Posts

hi,

Like I mentioned previously, I created a FileVelocityResourceListener that extends the liferay VelocityResourceListener. The code I used what apache had for their fileResourceLoader, making modifications to match the new api. Created a jar of it, deployed as ext plugin. Added this to the portal-ext.properties file:

##velocity property update
velocity.engine.resource.listeners=com.liferay.portal.velocity.ServletVelocityResourceListener,com.liferay.portal.velocity.JournalTemplateVelocityResourceListener,com.liferay.portal.velocity.ThemeLoaderVelocityResourceListener,com.liferay.portal.velocity.ClassLoaderVelocityResourceListener,velocity.FileVelocityResourceListener


The last one is the resource listener that I created and added. Finally, restarted the server.

Thanks,
Sasipriya
Jay Patel
RE: using custom velocity properties in the theme
August 24, 2012 12:42 PM
Answer

Jay Patel

Rank: Regular Member

Posts: 116

Join Date: February 23, 2010

Recent Posts

Sweet..