- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can CMS_FOR be used to iterate over pages in the Page store?
I have a CMS_FUNCTION and Query, and use CMS_FOR to iterate over each row in the entity. This works well, but I would like to do the same thing, but instead of iterating over rows in a table, I want to iterate over pages in the Page store.
Is it possible to pass a parent folder as the Object in a CMS_FOR, and iterate over the list of pages? Ultimately, if this is possible, I want to dynamically built a list (<li>) of CMS_REF links which use these pages. I'm aware I could add a link template, or catalog, or something to make the pages select-able, but I'm talking about 1000 pages, so I don't want to have to select each one for use in a list or catalog, I would rather just pass the parent folder uid, and grab all the children pages in that folder.
- Labels:
-
Developers
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

