掲示板
Repeatable Fields from Web content in ADT
7年前 に Pierre-François Fiat によって更新されました。
Repeatable Fields from Web content in ADT
New Member 投稿: 7 参加年月日: 15/02/12 最新の投稿
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
7年前 に Pierre-François Fiat によって更新されました。
RE: Repeatable Fields from Web content in ADT
New Member 投稿: 7 参加年月日: 15/02/12 最新の投稿
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 ?
7年前 に Pierre-François Fiat によって更新されました。
RE: Repeatable Fields from Web content in ADT (回答)
New Member 投稿: 7 参加年月日: 15/02/12 最新の投稿
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 !
3年前 に Salvatore Taddeo によって更新されました。
RE: Repeatable Fields from Web content in ADT
New Member 投稿: 5 参加年月日: 19/07/10 最新の投稿
Thanks Pierre, You helped me a lot!