Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
35 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.
35 posts Page 4 of 4

Who is online

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

Users browsing this forum: Majestic-12 [Bot] and 2 guests

cron