掲示板

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
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 2
for 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 emoticon
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 :

&lt;#assign text = con.elementText("dynamic-content") /&gt; ${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 :

&lt;#assign subfields = con.elements("dynamic-element")&gt;


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,

&lt;#list subfields as subfield &gt;
 &lt;#if subfield.attributeValue("name") == "telephone"&gt;
  &lt;#assign text = subfield.elementText("dynamic-content") /&gt; ${text}
 <!--#if-->
<!--#list-->


I hope it will help someone one day emoticon
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!