Message Boards

How to sort web content iterable items.

Amit Sharma, modified 4 Years ago.

How to sort web content iterable items.

Junior Member Posts: 35 Join Date: 10/17/18 Recent Posts
Hello Exprests,I am using the liferay 7.1.2 CEI have created web content using the structure and template.Now i have created the web content added multiple items clicking on + sign. Whenever we click on + new item added at bottom of previous one.Is there any way to sort those items. As customer want to see the image first which he added at recently. all recent item will come down to the first image.

Thanks
-Amit 
thumbnail
Andrew Jardine, modified 4 Years ago.

RE: How to sort web content iterable items.

Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Amit, If I understand what you are saying, every time a new image is added, someone is updating that web content and adding the image to the list? If that is the case, then I would say you have applied the structured content incorrectly. If you need to allow images to be added (over time), and also sorted in DESC order based on create date, then a better solution would be to add a content item for EACH image and then use an Asset Publisher with the appropriate configuration to show them.
Amit Sharma, modified 4 Years ago.

RE: How to sort web content iterable items.

Junior Member Posts: 35 Join Date: 10/17/18 Recent Posts
My Structure as below 
{
    "availableLanguageIds": [
        "ar_SA"
    ],
    "defaultLanguageId": "ar_SA",
    "fields": [
        {
            "label": {
                "ar_SA": "galleryName"
            },
            "predefinedValue": {
                "ar_SA": ""
            },
            "style": {
                "ar_SA": ""
            },
            "tip": {
                "ar_SA": ""
            },
            "dataType": "string",
            "indexType": "keyword",
            "localizable": true,
            "name": "galleryName",
            "readOnly": false,
            "repeatable": true,
            "required": false,
            "showLabel": true,
            "type": "text",
            "nestedFields": [
                {
                    "label": {
                        "ar_SA": "galleryDescription"
                    },
                    "predefinedValue": {
                        "ar_SA": ""
                    },
                    "style": {
                        "ar_SA": ""
                    },
                    "tip": {
                        "ar_SA": ""
                    },
                    "dataType": "string",
                    "indexType": "text",
                    "localizable": true,
                    "name": "galleryDescription",
                    "readOnly": false,
                    "repeatable": false,
                    "required": false,
                    "showLabel": true,
                    "type": "textarea"
                },
                {
                    "label": {
                        "ar_SA": "coverImage"
                    },
                    "predefinedValue": {
                        "ar_SA": ""
                    },
                    "style": {
                        "ar_SA": ""
                    },
                    "tip": {
                        "ar_SA": ""
                    },
                    "dataType": "image",
                    "fieldNamespace": "ddm",
                    "indexType": "text",
                    "localizable": false,
                    "name": "coverImage",
                    "readOnly": false,
                    "repeatable": false,
                    "required": false,
                    "showLabel": true,
                    "type": "ddm-image"
                },
                {
                    "label": {
                        "ar_SA": "Date of Event"
                    },
                    "predefinedValue": {
                        "ar_SA": ""
                    },
                    "style": {
                        "ar_SA": ""
                    },
                    "tip": {
                        "ar_SA": ""
                    },
                    "dataType": "date",
                    "fieldNamespace": "ddm",
                    "indexType": "",
                    "localizable": true,
                    "name": "DateOfEvent",
                    "readOnly": false,
                    "repeatable": false,
                    "required": false,
                    "showLabel": true,
                    "type": "ddm-date"
                },
                {
                    "label": {
                        "ar_SA": "detailsGalleryPage"
                    },
                    "predefinedValue": {
                        "ar_SA": ""
                    },
                    "style": {
                        "ar_SA": ""
                    },
                    "tip": {
                        "ar_SA": ""
                    },
                    "dataType": "link-to-page",
                    "fieldNamespace": "ddm",
                    "indexType": "",
                    "localizable": true,
                    "name": "detailsGalleryPage",
                    "readOnly": false,
                    "repeatable": false,
                    "required": false,
                    "showLabel": true,
                    "type": "ddm-link-to-page"
                }
            ]
        }
    ]
}
Template:
<div class="container">
&nbsp; &nbsp; <div class="row">
&nbsp; &nbsp; &nbsp; &nbsp; &lt;#if galleryName.getSiblings()?has_content&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;#list galleryName.getSiblings() as cur_galleryName&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="col-lg-4 col-md-6 col-sm-6 col-12 padding15">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <article class="image-listing">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <figure>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="figure-img">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="${galleryName.detailsGalleryPage.getFriendlyUrl()}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <img src="${cur_galleryName.coverImage.getData()}">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </a>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </figure>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="video-title">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="${galleryName.detailsGalleryPage.getFriendlyUrl()}" class="the-title">${cur_galleryName.getData()}</a>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </article>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <!--#list-->
&nbsp; &nbsp; &nbsp; &nbsp; <!--#if-->
&nbsp; &nbsp; </div>
</div>&nbsp;
And I have created the webcontent Using 
Content --> WebContent + icon to add webcontent.
Form Content section i drag drop the webcontent on page.

These are my steps. I am not aware of Assets Publisher.