Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
I found the post/topic viewtopic.php?f=8&t=7173 to create a dynamic sitemap within couchcms and it works all ok but found that it's repeating pages and also it's outputting the images as well as .html files. The code I have is from the link viewtopic.php?f=8&t=7173&start=20#p24777

Below is the code I have

Code: Select all
<?php require_once( 'cms/cms.php' ); ?><cms:template title='Sitemap Page' clonable='0' hidden='1' commentable='0' executable='1' order='13'></cms:template><cms:content_type 'text/xml' /><cms:concat '<' '?xml version="1.0" encoding="' k_site_charset '"?' '>' />
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
           
    <cms:templates order='desc' >
   <cms:if (k_template_name eq 'sitemap.php') || (k_template_name eq 'globals.php') || (k_template_name eq 'globalstwo.php') || (k_template_name eq 'globalsthree.php') >
      <cms:else />
      <cms:if k_template_name eq 'index.php' >
         <url>
            <loc><cms:show k_template_link /></loc>
            <lastmod><cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d\TH:i:s+00:00' gmt='1' /></lastmod>
            <changefreq>daily</changefreq>
            <priority>1.0</priority>
         </url>     
         <cms:else />
            <url>
               <loc><cms:show k_template_link /></loc>
               <lastmod><cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d\TH:i:s+00:00' gmt='1' /></lastmod>
               <changefreq>daily</changefreq>
               <priority>0.9</priority>
            </url>         
         <cms:pages masterpage=k_template_name >     
            <url>
               <loc><cms:show k_page_link /></loc>
               <lastmod><cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d\TH:i:s+00:00' gmt='1' /></lastmod>
               <changefreq>daily</changefreq>
               <priority>0.8</priority>
            </url>
         </cms:pages>
      </cms:if>
   </cms:if>
</cms:templates>

</urlset>
<?php COUCH::invoke(); ?>


Is there a way to not display the image files, for example some lines are below from the sitemap file
Code: Select all
<url>
<loc>https://www.dcfinearts.uk/gallery/img06.html</loc>
<lastmod>2023-11-18T12:03:03+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://www.dcfinearts.uk/gallery/img05.html</loc>
<lastmod>2023-11-18T12:05:04+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>


Also if can not repeat the pages like the output below
Code: Select all
<url>
<loc>https://www.dcfinearts.uk/gun-dog-paintings/</loc>
<lastmod>2024-05-15T10:47:48+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://www.dcfinearts.uk/gun-dog-paintings/</loc>
<lastmod>2024-05-07T17:22:37+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://www.dcfinearts.uk/limited-edition-prints/</loc>
<lastmod>2024-05-15T10:47:48+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://www.dcfinearts.uk/limited-edition-prints/</loc>
<lastmod>2024-05-11T10:45:26+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://www.dcfinearts.uk/enquiry-confirmation/</loc>
<lastmod>2024-05-15T10:47:48+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://www.dcfinearts.uk/enquiry-confirmation/</loc>
<lastmod>2023-08-25T15:37:39+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
Think I just managed to solve it with the following code

Code: Select all
<?php require_once( 'cms/cms.php' ); ?><cms:template title='Sitemap Page' clonable='0' hidden='1' commentable='0' executable='1' order='13'></cms:template><cms:content_type 'text/xml' /><cms:concat '<' '?xml version="1.0" encoding="' k_site_charset '"?' '>' />
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
           
   <cms:templates order='asc' >
       <cms:if k_template_name eq 'index.php'>
           <url>
               <loc><cms:show k_template_link /></loc>
               <lastmod><cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d\TH:i:s+00:00' gmt='1' /></lastmod>
               <changefreq>weekly</changefreq>
               <priority>1.00</priority>
           </url>
           <cms:else />
           <cms:if k_template_name eq 'limited-edition-prints.php'>
               <url>
               <loc><cms:show k_template_link /></loc>
               <lastmod><cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d\TH:i:s+00:00' gmt='1' /></lastmod>
               <changefreq>daily</changefreq>
               <priority>1.00</priority>
           </url>
               <cms:else />
               <cms:if k_template_name eq 'gun-dog-paintings.php'>
               <url>
               <loc><cms:show k_template_link /></loc>
               <lastmod><cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d\TH:i:s+00:00' gmt='1' /></lastmod>
               <changefreq>daily</changefreq>
               <priority>1.00</priority>
           </url>
               <cms:else />
                   <cms:if (k_template_name ne 'globals.php') && (k_template_name ne 'globalstwo.php') && (k_template_name ne 'globalsthree.php') && (k_template_name ne 'gallery.php') >
                   <url>
               <loc><cms:show k_template_link /></loc>
               <lastmod><cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d\TH:i:s+00:00' gmt='1' /></lastmod>
               <changefreq>monthly</changefreq>
               <priority>0.8</priority>
            </url>
                       
                       <cms:if (k_template_name eq 'gallery.php') >
                       <url>
                       <loc></loc>
                       </url>
           <cms:else />
<cms:folders masterpage=k_template_name>
        <url>
            <loc><cms:show k_folder_link /></loc>
        </url>
    </cms:folders>
               
               <cms:if k_template_is_clonable >
               <cms:pages masterpage=k_template_name>
               <url>
                  <loc><cms:show k_page_link /></loc>
               <lastmod><cms:date "<cms:if k_page_modification_date='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else /><cms:show k_page_modification_date /></cms:if>" format='Y-m-d\TH:i:s+00:00' gmt='1' /></lastmod>
                   <changefreq>weekly</changefreq>
               <priority>1.0</priority>
               </url>
      </cms:pages>
               </cms:if>

</cms:if>
                       
                   </cms:if>
           </cms:if>
           </cms:if>
       </cms:if>
   </cms:templates>

</urlset>
<?php COUCH::invoke(); ?>
2 posts Page 1 of 1