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 3 of 4
@Robert
when i type domain.com/sitemap.php my url is automatically turning to domain.com/sitemap/

This behaviour seems to point to the fact that you have turned prettyURLs on for your site.
The 404 error suggests that you have not updated your .htaccess file (using gen_htaccess.php) to include the sitemap template (which incidentally also explains why Google tools is throwing the error as the sitemap is actually unavailable to it).

Please update your .htaccess and let me know if the problem is solved. Thanks.
Yup thats the problem.. I updated .. its now working pretty fine .. Thanks alot :)
I had a problem while creating the sitemap template. This was my first version of the template:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<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' title='Sitemap' hidden='1' order='12'>
    <cms:if (k_template_name ne 'globals.php') && (k_template_name ne '404.php') && (k_template_name ne '503.php') && (k_template_name ne 'header-images.php') && (k_template_name ne 'slider.php') && (k_template_name ne 'seo.php') && (k_template_name ne 'stats.php') && (k_template_name ne 'sitemap.php')>
      <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>
        </url> 
      </cms:pages>
    </cms:if>
  </cms:templates>

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

I didn't want the client to see the sitemap in the Admin Panel so I added:

Code: Select all
<cms:templates order='asc' title='Sitemap' hidden='1' order='12'>

But after that it still remains visible for the client and also the title in the menu remains 'sitemap.php' instead of 'Sitemap'.

I couldn't find anything wrong in the template, so I asked Kamran if he could help. He found out that the problem seemed to be that XML has problems if any character (even a blank line) appears before its very first line. The solution was to put all Couch specific code on the same line as the XML opening tag so as not to generate a blank line.

So I ended up as follows (with the help of Kamran):

Code: Select all
<?php require_once( 'couch/cms.php' ); ?><cms:template title='Sitemap' hidden='1' order='12'></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 ne 'globals.php') && (k_template_name ne '404.php') && (k_template_name ne '503.php') && (k_template_name ne 'header-images.php') && (k_template_name ne 'slider.php') && (k_template_name ne 'seo.php') && (k_template_name ne 'stats.php') && (k_template_name ne 'sitemap.php')>
      <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>
        </url> 
      </cms:pages>
    </cms:if>
  </cms:templates>

</urlset>
<?php COUCH::invoke(); ?>
when i am visiting my sitemap its not being updated .. only two urls are generated in it .. is it because all my other pages having future dates in publish date? and I found a new page in my ftp p7h.php it is showing this

<?php

if( !defined('K_COUCH_DIR') ) die(); // cannot be loaded directly

function p7h( $o ){
return clone( $o );
}

I just turned on cache..before that.. is it because of that?
The 'p7h.php' is a core file and has nothing to do with the problem at hand.

Since the sitemap is being generated using cms:pages tag, as you know, pages with their publish date in the future will not be fetched. You can change this by using show_future_entries='1' parameter with cms:pages tag.

Hope this helps.
Perfectly :)
Geting "Out of memory" error in sitemap
A recent post on the forum reported running out of memory situation while listing large number of pages.

Here is the post with the fix to the problem:
viewtopic.php?f=4&t=7286&p=10167#p10167
KK wrote: Hi Potato,

We can use Couch itself to create a dynamically generated sitemap.

This is what a typical sitemap looks like (used http://www.xml-sitemaps.com to get this and trimmed down the entries to only two)
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- created with Free Online Sitemap Generator www.xml-sitemaps.com -->

<url>
  <loc>http://www.yoursite.com/</loc>
  <lastmod>2012-09-10T13:30:35+00:00</lastmod>
  <changefreq>daily</changefreq>
</url>
<url>
  <loc>http://www.yoursite.com/about-us/</loc>
  <lastmod>2012-09-10T13:30:35+00:00</lastmod>
  <changefreq>daily</changefreq>
</url>

</urlset>

It is just a XML list of pages.
The repeating element here is the <url>..</url> block that contains information about each page in the site.

If we were to generate such a list using Couch, we can create a separate template to output the XML list (let us call it 'sitemap.php').
In this template, we paste the code above.
We'll have to modify the XML part as it has some quirks that have been discussed in our docs where we create a RSS feed (http://www.couchcms.com/docs/concepts/rss-feeds.html).

To output the <url>..</url> blocks for each page, we use only one block and then enclose with cms:pages tag.

A typical Couch site consists of more than one template, so we either use the cms:pages loop multiple times specifying a different template (the 'masterpage' parameter) each time or for a more generic solution, we can use the cms:templates tag (http://www.couchcms.com/docs/tags-refer ... tes-1.html) to loop through the available non-hidden templates and feed the names to cms:pages tag.

Here is a complete working 'sitemap.php' template. You can download it and use it as-in in your site:
sitemap.zip

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<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: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>
         </url>
      </cms:pages>
   </cms:templates>

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

Hope this helps. Do let me know.
P.S. If you have not yet turned caching on for your site (in config.php), now is the time to do so :)


H there,

just wondering, how these files should be implemented? right now I've downloaded your sitemap.php file and also have my basic .htaccess, need assistance here can't get a handle on it.
Мaybe useful for someone. Мore classic view with templates & priority :)
Code: Select all
<cms:templates order='desc' >
   <cms:if (k_template_name eq 'sitemap.php') || (k_template_name eq 'globals.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>
How about links to folders? How should that be done?
40 posts Page 3 of 4
cron