Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
40 posts Page 2 of 4
You should try submitting 'sitemap/'

If that doesn't work, then providing us a link or code of the sitemap would be helpful to troubleshoot the matter. You can always edit your post at a later date and remove the link if you like.
hi, I finally got round to implementing the dynamic sitemap.php (having just tested it out locally) ... I used KK's posted sitemap.php template.

I didn't want the client to see sitemap in the Admin Panel so I added
Code: Select all
<cms:template title='Site map' clonable='0' hidden='1' commentable='0' executable='1' order='1000' />

I initially got a 404 response on submitting the sitemap via Google Webmasters - this was because I had set executable to '0'. I wonder if this could solve the problem for you too Martijn?

I also had to remember to slightly adapt KKs template so that the events with published date in the future were included in the sitemap:
Code: Select all
<cms:pages masterpage=k_template_name show_future_entries='1'>


I ended up excluding quite a number of templates from within <cms:pages> so decided to list the static pages of the site in the sitemap and then dynamically generate those from the 2 templates where the client will be adding content:
Code: Select all
<cms:template title='Site map' clonable='0' hidden='1' commentable='0' executable='1' order='1000' />         
   <cms:templates order='asc' >
      <cms:pages masterpage=k_template_name show_future_entries='1' id='NOT 29, 9'>
      <cms:if (k_template_name eq 'events.php') || (k_template_name eq 'musings.php') >
         <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>
         </url>
      </cms:if>
  </cms:pages>
</cms:templates>

Just edited my posting because I did get a 404 error from Google even after I'd changed "executable" to '1' (initially it all looked OK when I clicked on "test sitemap" - no errors found). So I got the 404 error when I clicked on "submit sitemap" BUT I then refreshed the page and the error message disappeared and the status of the php sitemap is now 'pending' and looking OK. A bit unsatisfactory I know, as I can't really tell you what happened.

Hope this all makes sense!
A very easy way to test as to what Google would be seeing is to first access the template yourself as an ordinary user.

Access the sitemap in a second browser (in which you are not logged in as admin/super-admin).
If you see the output right, there is no reason for Google to complain. If, on the other hand, you get a 404 or some other response it can be investigated right there.

@potato, using the method above would have shown the error thrown accessing a template set with executable='0'. Also if you are using caching, a 404 response will also get cached until something (content in editable region) changes anywhere on the site. This could be the reason why you got 404 even after making the template executable.
To bust the cache make some dummy change to any content or turn off caching temporarily and turn it on back only when the site is finalized.

Hope this helps.
very useful to know that something like a 404 response can get cached - I've made a mental note of this!
Thanks for all your help. I got it working now. I think it had something to do with the cache.

How can I hide some pages (like globals.php) in the site map?
I did it this way:

Code: Select all
<cms:if (k_template_name ne 'globals.php') && (k_template_name ne 'backup.php') && (k_template_name ne 'explorer.php') && (k_template_name ne 'privacy.php') && (k_template_name ne 'cookies.php') && (k_template_name ne 'termsandconditions.php') && (k_template_name ne 'sitemap.php') >
         <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>
         </url>
      </cms:if>
Yes, that works. Thank you, potato! :)
@potato
I'll make one little optimization to your code -
we'll check the template name before the pages loop and not within it. It is wasteful to be doing it for every single page of a template that has to be skipped.
This could be the revised code:
Code: Select all
<cms:templates order='asc' >
   <cms:if (k_template_name eq 'events.php') || (k_template_name eq 'musings.php') >
      <cms:pages masterpage=k_template_name show_future_entries='1' id='NOT 29, 9'>
         <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>
         </url>
      </cms:pages>
   </cms:if>
</cms:templates>

Now if a template is to be skipped the pages loop is also skipped.
Hope this helps.
thanks KK, implemented ... and something I need to watch out for - efficient code!
Hello I tried your file sitemap.php but the problem is when i try to visit the path of file through browser it's showing not found. And one more thing is when i type domain.com/sitemap.php my url is automatically turning to domain.com/sitemap/ like folder what might be the cause.? and also let me know if anything added to sitemap.php because I just downloaded and changed the path of cms and uploaded to server that's it, and tried testing sitemap in google webmastertools which has shown 'unacceptable format' window.
40 posts Page 2 of 4

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests