Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
9 posts Page 1 of 1
sitemap.zip
(2.86 KiB) Downloaded 93 times
For a long time dealing with sitemaps in Couch has been sub-par and required a lot of manual work to exclude certain pages and templates. This usually comes with lots of confusing if statements that we are forced to analyse every time we wish to make some change to a sitemap on a site.
You are either using the original sitemap template suggested by @KK in this thread, or have your own custom sitemap. If you are using the sitemap template provided by KK, you have probably noticed that you have to add in a lot of manual entries for things such as a list-view URL on a cloned template.

Today I am attaching something I have created that will hopefully alleviate some of the time consuming parts of managing a sitemap in couch.

this single template will allow you to manage both cloned and single page templates from the sitemap page in the admin panel. You will have the power to select whether a cloned template outputs URLs for its posts, for its folder URLs, for the template list view. All separately of course, allowing full control over every single template added.
The sitemap will automatically exclude all non-executable templates (often used to define regions for other templates), every other type of page or template can be excluded from the admin panel page.

Furthermore, you can exclude individual posts by adding a list of comma separated post IDs to the text field allowing you full control via the admin panel for your websites sitemap.

Note: Please let me know if there are any issues with nested templates, I have only done limited testing in that area.

Installation instructions:

Place both files into the root of your website, open sitemap.php in your favourite texteditor and edit the first line
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>

to make sure it points to your couch install directory, just like any other template on your site.

If you wish to remove the sitemap stylesheet, please change line 2. From:
Code: Select all
<cms:content_type 'text/xml' /><cms:concat '<' '?xml version="1.0" encoding="' k_site_charset '"?' '>' /><cms:concat '<' '?xml-stylesheet type="text/xsl" href="' k_site_link 'main-sitemap.xsl"?' '>' />

To:
Code: Select all
<cms:content_type 'text/xml' /><cms:concat '<' '?xml version="1.0" encoding="' k_site_charset '"?' '>' />

and delete the 'main-sitemap.xsl' as it will not be needed.

You may also re-style the sitemap to whatever you see fit. The provided stylesheet is what I use for my sites, it is not a requirement to have a stylesheet for a sitemap, it adds nothing but making the sitemap easier to read for you as a developer.

I hope everyone finds this template as useful as I have! :)

sitemap.zip
(2.86 KiB) Downloaded 93 times
Image
This is a really nice update to the Couch generated sitemap with push button ease-of-use. I modified it for my own purposes to allow setting different change frequencies for different templates, and to let me list pages for different archive periods on clonable templates where appropriate.

I bet most people can think of their own tweaks to suit particular needs. The clean structure and organization of the template made it easy to make those modifications. But the original template provides a simple, straightforward, fully functional sitemap that's easy to use right out of the box.

There were a couple of things I noticed that I think would be worth adding to the standard template.

1. I've never actually seen an xml style sheet before, so that's cool. But I think you probably want to also credit Couch in the header. Something like:
Code: Select all
Generated dynamically by <a href="http://couchcms.com">CouchCMS</a> with <a href="http://bartonsweb.co.uk/">Bartonsweb</a>'s sitemap template.

You could also add a comment just before the cms:template tag, for sites that don't use the stylesheet:
Code: Select all
<!-- Sitemap generated dynamically by CouchCMS (http://www.couchcms.com) with Bartonsweb's sitemap template (http://bartonsweb.co.uk/) -->

2. It's not unusual for me to hide templates from the client when they don't need to work with them, just to keep things simple. But I still want those templates to show up in the sitemap. KK's original sitemap idea overlooked the same issue.

I think the cms:templates tags should be configured to show hidden templates:
Code: Select all
<cms:templates show_hidden='1' order='asc'>

This is a very handy website management tool. Will be updating all my sitemaps right away. Thanks for sharing!
Great work! This is really helpful to me.
tim wrote: This is a really nice update to the Couch generated sitemap with push button ease-of-use. I modified it for my own purposes to allow setting different change frequencies for different templates, and to let me list pages for different archive periods on clonable templates where appropriate.

I bet most people can think of their own tweaks to suit particular needs. The clean structure and organization of the template made it easy to make those modifications. But the original template provides a simple, straightforward, fully functional sitemap that's easy to use right out of the box.

There were a couple of things I noticed that I think would be worth adding to the standard template.

1. I've never actually seen an xml style sheet before, so that's cool. But I think you probably want to also credit Couch in the header. Something like:
Code: Select all
Generated dynamically by <a href="http://couchcms.com">CouchCMS</a> with <a href="http://bartonsweb.co.uk/">Bartonsweb</a>'s sitemap template.

You could also add a comment just before the cms:template tag, for sites that don't use the stylesheet:
Code: Select all
<!-- Sitemap generated dynamically by CouchCMS (http://www.couchcms.com) with Bartonsweb's sitemap template (http://bartonsweb.co.uk/) -->

2. It's not unusual for me to hide templates from the client when they don't need to work with them, just to keep things simple. But I still want those templates to show up in the sitemap. KK's original sitemap idea overlooked the same issue.

I think the cms:templates tags should be configured to show hidden templates:
Code: Select all
<cms:templates show_hidden='1' order='asc'>

This is a very handy website management tool. Will be updating all my sitemaps right away. Thanks for sharing!


Thank you for your feedback Tim!

1. When I added the stylesheet I just uploaded the stylesheet I use for my client sites, I overlooked the text at the top entirely. I have updated the stylesheet for use on other sites. However, it should be noted, search engines will not consume the stylesheet or any of the html/text from it. If you view source on the sitemap, you will only see the XML for the sitemap. the XSL stylesheet is just to make it human read-able for developers looking at the page to check URLs.

2. This was overlooked by me, I based this template off of the original idea, I use hidden templates for both hiding pages I don't want clients messing with and hiding templates that have no content/editable regions. At any rate, whether a template is hidden or shown, if it has some front-end output (it is executable), it should be managed by the user in regards to the sitemap. I have updated the main post with the changes!
Image
Hi,

It looks great. Only one trouble: my urls count is stuck at 1011 URL's whereas my website got more than 4000, at https://vietnamsales.com/sitemap/

Any idea why?

Cheers,
Paolo
PaoloE wrote: Hi,

It looks great. Only one trouble: my urls count is stuck at 1011 URL's whereas my website got more than 4000, at https://vietnamsales.com/sitemap/

Any idea why?

Cheers,
Paolo


Hi Paolo,
I have tried loading the url but you are missing the main-sitemap.xsl file in your websites root folder. Please follow the steps in the main post to either remove the xml stylesheet from the sitemap, or include the file so I can further debug your issue.
Image
PaoloE wrote: It looks great. Only one trouble: my urls count is stuck at 1011 URL's whereas my website got more than 4000
Any idea why?

This happens if limit was not set explicitly for 'cms:pages' tag. By default it caps up to 1000 pages in result (you can see actual limit by placing a 'cms:dump' tag inside and limit is among the variables.


Find in sitemap.php something like

<cms:pages masterpage=k_template_name>

And change it to following to have as many links as you have actual pages (1 million theoretical limit should do it)

<cms:pages masterpage=k_template_name limit='1000000'>
Thanks, Trendoman,

That solved the issue!

Have a wonderful day.

Best,
Paolo
This works like a charm, thank you Bartonsweb!
9 posts Page 1 of 1

Who is online

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

Users browsing this forum: No registered users and 3 guests