How To Change Sequence of the content type on page

2025/01/29 10:12 AM

I have created one Page Content Type Called Landing page It has currently 6 reusable content type configured. now on the admin panel when user changes order of these content types inside landing page content type. i want to retrieve that order and updated my landing page template.

So i wanted to know if kentico has pre-built functionality for that if not then can anybody suggest how can i implement programmatically ??


Environment

  • Xperience by Kentico version: [30.0.1]
  • .NET version: [8]

Answers

2025/01/29 5:43 PM

Creator,

By 'It has currently 6 reusable content type configured' do you mean that you have a Pages and Reusable Content field type that can select from 6 reusable content types? If so, it should already handle ordering, as long as when you retrieve your primary content item you include the levels enough to grab the remaining items.

The model will return an IEnumerable<IContentItemFieldSource> but as long as you use the GetMappedResults, it will map it to the proper Content Type Classes for you to do type checking on. It will be in order.

var testPage = new ContentItemQueryBuilder().ForContentType(Testing.WebPage.CONTENT_TYPE_NAME, query => 
    query.WithLinkedItems(100, o=> o.IncludeWebPageData())
        .ForWebsite(_websiteChannelContext.WebsiteChannelName, includeUrlPath: true)
        .Where(where => where.WhereEquals(nameof(WebPageFields.WebPageItemID), 7))
        .TopN(1)
        )
    .InLanguage("en");
var mappedToPage = await _contentQueryExecutor.GetMappedWebPageResult<Testing.WebPage>(testPage);
if (mappedToPage.Any()) {
    var firstItem = mappedToPage.First();
    foreach(var section in firstItem.SectionsSystemSections) {
        if(section is Section.TestA testA) {
            var testing = testA.SectionTestAName;
        } else if(section is Section.TestB testB) {
            var testing = testB.SectionTestBName;
        } else if(section is Section.Widget widget) {
            // If you don't see the WebPageItem values, make sure your .WithLinkedItems has the optional ConfigureOptionsAction (query.WithLinkedItems(100, o=> o.IncludeWebPageData()))
            // Partial Widget Page <inlinewidgetpage web-page-id="@webPageID" initialize-document-prior="true"></inlinewidgetpage>
            // requires the WebPageItemID
            var testing = widget.SystemFields.WebPageItemID;
        }
    }
}
2025/01/30 2:20 AM
Answer

No, there is nothing in Xperience to do this for you, mostly because there is nothing in SQL to do this.

Check out this answer which I believe covers your use-case.

2025/01/31 2:26 PM

For me this sounds like having sub-content below a landing page or content within the landing page.

If sub content, I would add page content items under the langing page and reference the content items from the content hub there.

If you want to reorder content within the landing page, I would suggest using widgets and reference a single content item each there. Move the widgets instead the content item references in the landing page.

To answer this question, you have to login first.