Zum Hauptinhalt gehen

Can CMS_FOR be used to iterate over pages in the Page store?

Kommentare

3 Kommentare

  • Zendesk API User
    Author: felix_reinhold - 5/4/2017 7:33

    Hello Leland,

    you can use CMS_FOR  to iterate over any kind of iterable. Therefore you can iterate over all children of type "Page" of a "PageFolder" (e. g. PageStoreRoot). But you wrote, that you want to create links so I guess you meant the SiteStore. You have the same possibilities there - you can iterate over all children of type "PageRef" of a "PageRefFolder".

    Example :

    $-- First get the SiteStoreRoot. You could also get a specific folder from the SiteStore --$

    $CMS_SET(siteStoreRoot, #global.getStore(class("de.espirit.firstspirit.access.store.Store$Type").SITESTORE, true))$

    $CMS_SET(recursive, true)$ $-- Set to true if you want to iterate recursivley over subfolders too --$

    $CMS_FOR(pageref, siteStoreRoot.getChildren(class("de.espirit.firstspirit.access.sitestore.PageRef"),recursive))$

         $--now you can create a link--$

         $CMS_REF(pageref)$

    $CMS_END_FOR$

    I just wrote this with my smartphone with no access to the api reference. Therefore there might be some small mistakes or typos in there.

    Best regards

    Felix

    0
  • Zendesk API User
    Author: marza - 5/9/2017 8:56

    Hello Leland,

    another possibility might be, if you want to generate a kind of menu or sitemap there is built-in support called Navigation function in FirstSpirit for that:

    Creating Sitemaps for Search Engines

    http://www.e-spirit.com/odfs52/template-develo/template-syntax/functions/header/navigation/

    Regards,

    Marian

    0
  • Zendesk API User
    Author: mbergmann - 5/16/2017 18:19

    Hi Leland,

    do you really mean the Page store (green)? If yes, please keep in mind that a CMS_REF to page objects will only work in the SA preview but not on the generated pages because page objects don't have an URL.

    Michael

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.