Skip to main content

Get latest created page and released page

Comments

1 comment

  • Zendesk API User
    Author: felix_reinhold - 7/28/2021 11:44

    Hi Geetha,

    that's pretty straightforward:

    Create a FS_REFERENCE that is filtered to pagereffolders. I call it st_folder for this example:

    $CMS_SET(sv_newest_pageref, st_folder.get().getChildren(class("de.espirit.firstspirit.access.store.sitestore.PageRef"), true)

                                                 .filter(pageref -> pageref.isInReleaseStore())

                                                 .sort(pageref -> pageref.getReleaseRevision().getCreationTime())

                                                 .last())$

    $-- Now you should have the newest page from the folder. Access the FormData of its page to get the corresponding contents --$

    $CMS_VALUE(sv_newest_pageref.page.formData.st_headline)$

    Most of the time you're working with the pageref instead of the page therefore - that's why I implemented it with the PageRef and PageRefFolder in this case.

    If you really want to use the Page, then filter the FS_REFERENCE to type pagefolder, change the class in getChildren to pagestore.Page and of course change the variable names ;-)

    I wrote the code directly here as acomment so I didn't test it and there might be syntax erors.

    Best regards

    Felix

    0

Please sign in to leave a comment.