Fórum
Repeatable Fields from Web content in ADT
Pierre-François Fiat, modificado 7 Anos atrás.
Repeatable Fields from Web content in ADT
New Member Postagens: 7 Data de Entrada: 12/02/15 Postagens Recentes
Hello,
I would like to display repeatable fields in my ADT.
My Web Content has the following structure:
--contact : repeatable="true"
---- telephone (inside contact) : repeatable="true"
I would like to display the content of all the "contact" fields with all the subfields "telephone" linked to them.
my web content has the following data :
-- contact = A
---- telephone=0000 / telephone=0001
-- contact = B
---- telephone=0002
I would like to see
So far, I can detect the nodes that contains Contact and Telephone but I can not display the content of the fields:
I have
I am using Liferay 7 GA2.
Does anyone know how to display the data ?
Thank you by advance
I would like to display repeatable fields in my ADT.
My Web Content has the following structure:
--contact : repeatable="true"
---- telephone (inside contact) : repeatable="true"
I would like to display the content of all the "contact" fields with all the subfields "telephone" linked to them.
my web content has the following data :
-- contact = A
---- telephone=0000 / telephone=0001
-- contact = B
---- telephone=0002
I would like to see
A 0000 0001 B 0002
So far, I can detect the nodes that contains Contact and Telephone but I can not display the content of the fields:
<#list entries as entry>
<#assign assetRenderer = entry.getAssetRenderer()>
<#assign docXml = saxReaderUtil.read(assetRenderer.getArticle().getContent()) />
<#assign contacts = docXml .getRootElement().selectNodes("//dynamic-element[@name='contact']") />
<#list contacts as con>
1
<#assign telephones = con.selectNodes("//dynamic-element[@name='telephone']") />
<#list telephones as tel>
2
<!--#list-->
<!--#list-->
<!--#list-->
I have
1 2 2 2 1 2 2 2for a result so I deduce I retrieve correctly the nodes for contact but not for telephone.
I am using Liferay 7 GA2.
Does anyone know how to display the data ?
Thank you by advance
Pierre-François Fiat, modificado 7 Anos atrás.
RE: Repeatable Fields from Web content in ADT
New Member Postagens: 7 Data de Entrada: 12/02/15 Postagens Recentes
I have found the first part of my answer :
to display the data of a node :
Now I need to display the repeatable fields inside repeatable fields.
Does someone knows how to do it ?
to display the data of a node :
<#assign text = con.elementText("dynamic-content") /> ${text}
Now I need to display the repeatable fields inside repeatable fields.
Does someone knows how to do it ?
Pierre-François Fiat, modificado 7 Anos atrás.
RE: Repeatable Fields from Web content in ADT (Resposta)
New Member Postagens: 7 Data de Entrada: 12/02/15 Postagens Recentes
Sorry for the monologue...
To get the fields from the the parent node I did :
Of course this gives me all the sub-fields (if the web content structure has more than just telephone). In order to parse to get only the "telephone" I did this way,
I hope it will help someone one day
And if you know cleaner code, please please SHARE IT !
To get the fields from the the parent node I did :
<#assign subfields = con.elements("dynamic-element")>
Of course this gives me all the sub-fields (if the web content structure has more than just telephone). In order to parse to get only the "telephone" I did this way,
<#list subfields as subfield >
<#if subfield.attributeValue("name") == "telephone">
<#assign text = subfield.elementText("dynamic-content") /> ${text}
<!--#if-->
<!--#list-->
I hope it will help someone one day
And if you know cleaner code, please please SHARE IT !
Salvatore Taddeo, modificado 3 Anos atrás.
RE: Repeatable Fields from Web content in ADT
New Member Postagens: 5 Data de Entrada: 10/07/19 Postagens Recentes
Thanks Pierre, You helped me a lot!