[opencms-dev] Nested container doesn't follow its parent

Jochen Graf j.graf at alkacon.com
Tue Oct 26 19:17:54 CEST 2021


Hi Corrado,

your post from this morning was not sent to the list because the 
attached images were too large. Sorry for this.

You are right: the nested container / tabs example in the OpenCms 
documentation does not explain that reordering the labels is not possible.

If order is important, your Item content (the parent content) is 
responsible to provide a unique and persistent ID for the nested containers.

There is no simple solution to do this if you cannot ask your editors 
for such an ID. One solution would be to add a hidden field to your Item 
Schema not visible in the content editor [1] and to initialize the field 
with a random UUID by means of a Item content handler extending 
org.opencms.xml.content.CmsDefaultXmlContentHandler [2].

To be honest: in most situations it is better to rethink the nested 
container approach inside a for each loop. Maybe there is a better 
solution for your use case.

Best

Jochen

[1] 
https://documentation.opencms.org/opencms-documentation/content-in-opencms/defining-a-content-type/defining-the-contents-behavior/adjusting-the-contents-appearance-in-the-content-editor/hiding-schema-elements/
[2] 
https://documentation.opencms.org/javadoc/core/org/opencms/xml/content/CmsDefaultXmlContentHandler.html

>
> Hi all,
>
> I was reading:
>
> https://documentation.opencms.org/opencms-documentation/content-in-opencms/formatters-and-their-configuration/nested-containers/index.html  <https://documentation.opencms.org/opencms-documentation/content-in-opencms/formatters-and-their-configuration/nested-containers/index.html>
>
> and I was wondering what would happens to the nested containers when I move labels.
>
> I have a similar situation (rows instead of labels, see attachments) and when I change their positions inner container does not follow its parent.
>
> My core code is:
>
>
> <c:forEach var="item" items="${content.valueList.Item}" varStatus="status">
> ... some code ...
> <a href="#elenco-combinati-${status.index}" data-toggle="collapse">Combinato con</a>
> <div id="elenco-combinati-${status.index}" class="collapse>
> 	<cms:container name="combinato-${status.index}" type="combinato">
> 		<p>Aggiungi combinato</p>
> 	</cms:container>
> </div>
> ... other some code ...
>
>
> I suppose ${status.count}, used in inner container name, has to be intended as position, so after parents move to new position children remains at their thus loosing correct reference to their parent.
>
> I am doing some tests to find a unique id to link parent and his child (es. parent uuid) but after:
>
> ${item.getContentValue()}
>
> in the forEach loop I can't go forward to find this uuid!
>
>
> @OpenCms teams:https://documentation.opencms.org/elementary-demo/tabs-accordion/  <https://documentation.opencms.org/elementary-demo/tabs-accordion/>  page does not exist.
>
>
> Kind regards.
>
> Corrado
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: step-1.jpg
> Type: image/jpeg
> Size: 37844 bytes
> Desc: step-1.jpg
> URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20211026/eb5a9f2f/attachment-0003.jpg  <http://lists.opencms.org/pipermail/opencms-dev/attachments/20211026/eb5a9f2f/attachment-0003.jpg>>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: step-2.jpg
> Type: image/jpeg
> Size: 97061 bytes
> Desc: step-2.jpg
> URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20211026/eb5a9f2f/attachment-0004.jpg  <http://lists.opencms.org/pipermail/opencms-dev/attachments/20211026/eb5a9f2f/attachment-0004.jpg>>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: step-3.jpg
> Type: image/jpeg
> Size: 52755 bytes
> Desc: step-3.jpg
> URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20211026/eb5a9f2f/attachment-0005.jpg  <http://lists.opencms.org/pipermail/opencms-dev/attachments/20211026/eb5a9f2f/attachment-0005.jpg>>
>

-- 
Alkacon Software GmbH & Co. KG  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20211026/7ade8b53/attachment.htm>


More information about the opencms-dev mailing list