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 4 of 4
Hi, I've got a question about using the dynamic sitemap. I've used it on numerous sites, and it works great. But I've come up against a problem, and I can't seem to solve it (might just be tired!)

I'm using this code:
Code: Select all
<cms:templates order='asc' >
   
   <cms:if (k_template_name eq 'sitemap.php') || (k_template_name eq 'global.php')>
      <cms:else />
      <cms:if k_template_name eq 'index.php' >........

Code cut short for brevity :)

The site I am working on has an option in couch to hide the page from the site navigation - If the user doesn't want the public to see the "about" page, they would select "No" from a dropdown in global.php. It still "exists", it just isn't accessible from the main navigation - and as such I wouldn't want it indexed.

My question is, how would I then incorporate this into the sitemap? I've tried this:
Code: Select all
<cms:pages masterpage="global.php">
        <cms:if view_about ="yes"><cms:set a_str=""  scope='global'/><cms:else /><cms:set a_str=" || (k_template_name eq 'about.php')"  scope='global'/></cms:if>
</cms:pages>
<cms:templates order='asc' >
  <cms:if (k_template_name eq 'sitemap.php') || (k_template_name eq 'global.php' a_str>

And this:
Code: Select all
<cms:if (k_template_name eq 'sitemap.php') || (k_template_name eq 'global.php' <cms:show a_str />>


But obviously couch doesn't like me putting variable inside the "if". Is there any way around this?
I've been working all day, so apologies if I'm missing something obvious here.

E
Go with this:

Code: Select all
<cms:pages masterpage="global.php">
        <cms:if view_about = "yes"><cms:set a_str="0"  scope='global'/><cms:else /><cms:set a_str="1"  scope='global'/></cms:if>
</cms:pages>
<cms:templates order='asc' >
  <cms:if (k_template_name eq 'sitemap.php') || (k_template_name eq 'global.php' ) || a_str >
     
Thanks trendoman, I'll have a look at it tomorrow. Gave up for the day a while ago!
I started to have a go at this again yesterday, but then noticed that there had been a new sitemap template designed by bartonsweb which pretty much does what I need. https://www.couchcms.com/forum/viewtopic.php?f=8&t=11000&p=28336#p28327

Couch is great!
Yeah, that is an awesome option for what you need :-) Right in time.
Hey there,

Today I noticed that sitemap is showing all cms:mosaic and cms:globals tag's elements as a page. My Sitemap is like this:
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:if k_template_name!='globals.php'>
    <url>
        <loc><cms:show k_template_link /></loc>
    </url>
   
    <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>
            </url>
        </cms:pages>
    </cms:if>
    </cms:if>
</cms:templates>

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


How can I solve this problem?
Please use the current version of Couch available form GitHub (https://github.com/CouchCMS/CouchCMS).
As it happens, this problem was rectified just three days back :)

Hope this helps.
Hey KK,
I see that version of Couch which is available in Github is 2.0 but I am using 2.1 beta right now. When I use version 2.0, will cms:mosaic and cms:globals tags be available?
Thanks
On https://github.com/CouchCMS/CouchCMS, click the 'Clone or download' dropdown on right and then 'Download zip'.
That is the 2.1 beta with most recent commits.

Hope this helps.
Hey KK
I installed the version in Github and It worked. Thank you so much :)
40 posts Page 4 of 4