Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Christian Freihoff
Make Changes in Web Content via Velocity Template?
May 9, 2013 8:10 AM
Answer

Christian Freihoff

Rank: Junior Member

Posts: 36

Join Date: December 3, 2012

Recent Posts

To display Web Content i just write into my template

1Authentification: $authentification.getData()


so it will retrieve the field named authentification that i have defined in the structure before.

No i am looking for a small tutorial or just for some tipps how i can make the shown web content editable. For example via a textfield input. What's the method to write something back to the structure defined web content field?

Thanks in advance
Bart Simpson
RE: Make Changes in Web Content via Velocity Template?
May 10, 2013 3:20 AM
Answer

Bart Simpson

Rank: Liferay Master

Posts: 524

Join Date: August 29, 2011

Recent Posts

The key to update a field dynamically is to retreive the JournalArticle's content using
1com.liferay.portlet.journal.model.JournalArticle.getContentByLocale
this will give the xml which contains the strucutre fields with populated data.
This xml can be modified / read using
1com.liferay.portal.kernel.xml.SAXReaderUtil

From inside velocity you can access this using $saxReaderUtil
and access individual fields using something like
1doc.selectSingleNode("/root/dynamic-element[@name='" + fieldName + "']/dynamic-content")
where
1doc
can be retrieved from SAXReaderUtil
Christian Freihoff
RE: Make Changes in Web Content via Velocity Template?
May 11, 2013 6:17 AM
Answer

Christian Freihoff

Rank: Junior Member

Posts: 36

Join Date: December 3, 2012

Recent Posts

okay thanks,

afaik we are already using the sax reader util in java coded parts. that in can be used also in velocity, would be great.

unfortunately i am not very advanced in velocity templates for liferay, so can i find any tutorial or code example anywhere?