Foros de discusión

Make Changes in Web Content via Velocity Template?

Christian Freihoff, modificado hace 10 años.

Make Changes in Web Content via Velocity Template?

Junior Member Mensajes: 36 Fecha de incorporación: 3/12/12 Mensajes recientes
To display Web Content i just write into my template

Authentification: $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
thumbnail
Bart Simpson, modificado hace 10 años.

RE: Make Changes in Web Content via Velocity Template?

Liferay Master Mensajes: 522 Fecha de incorporación: 29/08/11 Mensajes recientes
The key to update a field dynamically is to retreive the JournalArticle's content using
com.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
com.liferay.portal.kernel.xml.SAXReaderUtil

From inside velocity you can access this using $saxReaderUtil
and access individual fields using something like
doc.selectSingleNode("/root/dynamic-element[@name='" + fieldName + "']/dynamic-content")
where
doc
can be retrieved from SAXReaderUtil
Christian Freihoff, modificado hace 10 años.

RE: Make Changes in Web Content via Velocity Template?

Junior Member Mensajes: 36 Fecha de incorporación: 3/12/12 Mensajes recientes
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?