jorge_molinaalb
I'm new here

Extends the XML sitemap schema to include tags for images and videos.

Hi!

I just need to include tags for images and videos to the current sitemap schema.

Currently looks like the following picture:

373428_pastedImage_0.png

Code:

<CMS_HEADER> 

 

  <CMS_FUNCTION name="Navigation" resultname="sitemap"> 

        <CMS_PARAM name="expansionVisibility" value="all"/> 

        <CMS_PARAM name="wholePathSelected" value="0"/> 

        <CMS_PARAM name="siteMap" value="1"/> 

        <CMS_ARRAY_PARAM name="pageRefRendering"> 

            <CMS_ARRAY_ELEMENT index="0..10"><![CDATA[ 

                $CMS_IF(!#nav.ref.getPageLangSpec(#global.language).useExternalUrl())$ 

                    $CMS_IF(#nav.ref.getMultiPageParams(#global.language, #global.templateSet).getPageCount() > 1 && !#nav.ref.getMultiPageParams(#global.language, #global.templateSet).getData().isEmpty)$ 

                        $CMS_FOR(multiPage, #nav.ref.getMultiPageParams(#global.language, #global.templateSet).getData())$ 

                            <url> 

                                <loc>$CMS_VALUE(ref(#nav.ref, abs:1, contentId:multiPage.getId()).url.toString().split("/").map(x->x.urlEncode).toString("/"))$</loc> 

                                <lastmod>$CMS_VALUE(multiPage.getLastChange().format("yyyy-MM-dd'T'HH:mm:ssZ").substring(0, 22)+":00")$</lastmod>

                            </url> 

                        $CMS_END_FOR$ 

                    $CMS_ELSE$  

                        <url> 

                            <loc>$CMS_VALUE(ref(#nav.ref, abs:1).url.toString().split("/").map(x->x.urlEncode).toString("/"))$</loc> 

                            <lastmod>$CMS_VALUE(#nav.ref.page.changeDate().format("yyyy-MM-dd'T'HH:mm:ssZ").substring(0, 22)+":00")$</lastmod>

                        </url> 

                    $CMS_END_IF$ 

                $CMS_END_IF$ 

            ]]></CMS_ARRAY_ELEMENT> 

        </CMS_ARRAY_PARAM> 

    </CMS_FUNCTION>

</CMS_HEADER><?xml version="1.0" encoding="UTF-8"?> 

<urlset xmlns="http://www.google.com/schemas/sitemap/0.9"> 

$CMS_VALUE(sitemap)$

</urlset>

FirstSpirit SiteArchitect 5.2.200607.79090 (I)

0 Kudos
1 Reply
hoebbel
Crownpeak employee

Hello Jorge,

Maybe this example will help you to solve the problem:

$CMS_SET(mediastore,#global.userService.getStore(class("de.espirit.firstspirit.access.store.Store$Type").MEDIASTORE,true))$

$CMS_FOR(media,mediastore.getChildren(class("de.espirit.firstspirit.store.access.mediastore.MediaImpl"),true))$

$CMS_IF(media.getType()==0)$$-- 0 == FILE, 1 == PICTURE--$

$CMS_VALUE(media.getLastChanged())$<br>

$CMS_VALUE(ref(media).url)$<br>

$CMS_END_IF$

$CMS_END_FOR$

In line 1 I get the mediastore (release version).

In line 2 I iterate over all media (recursive)

Line 3 checks if it is a file (this might help with further queries if you want to find out if it is a video or an image)

Many greetings

Holger

0 Kudos