Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2

Unfortunately I've run into another problem :/. Before I added/implemented the custom routes commenting worked just fine. I didn't try it again directly afterwards, but now I'm realizing it's somehow not working anymore. The error I get displayed is "Page not commentable" - which can't be, since both the template allows comments as well as the individual pages (the option within the admin panel). Tried it as super admin as well as admin.

Any ideas? Encountered the problem before (although I couldn't find something while searching ghte forum) or is there something curcial I missed concerning custom routes and comments?
Hi Klaus,

I think the following paragraphs from Custom routes docs ( will tell us the reason -
The second change (adding K_IGNORE_CONTEXT to COUCH::invoke()) serves to instruct Couch to no longer apply the default views to this template. This is an important point - by doing this we are turning off Couch's default behavior of examining the URL used to access this template and then attaching one of the well-known views to it

*NOTE: strictly speaking, Couch still attaches one view to this template - the 'home-view'. So whatever the URL used to access the template, if we query Couch about the view it'll always report 'home-view'. Thing is, we'll now use the 'routes' module and no longer use Couch's interpretation of the current view so this is not a problem.

You'll remember that comments can only be attached to page-views. Now since page-view is no longer available with custom-routes, Couch refuses to attach comments to the template in question.

I'm not sure if this can be termed a bug or not. The whole idea of custom routes was to break out of the set 'page-view, list-view, folder-view' paradigm followed by default in Couch and then implement your own version of things.

You can easily mimic comments by using a dedicated template (say named 'comments.php') and them relating it to your template.

That said, I'll scrutinize this problem and see if we can bring in the built-in comments to play well with templates using custom routes.
Thanks again!! You think you'll manage in the near future? Otherwise I'll build my own comments.php like you suggested. But if you come up with a solution in the next days it would be for nothing :).
Hi Klaus,

I don't think I'll be able to work on this issue in the immediate future, I'm afraid.
You can safely build your own commenting system :)
Hi KK,

unfortunately my head is a bit twisted on how to set up the commenting system and I could need some help with the relations. Building one for a single template is quite easy, since it's the same as in the advanced tutorial, with the notes being the comments and the pads the cloned pages of the template.
But how would I handle it, if I would have more templates, like articles.php and videos.php? I could of course built several templates for the comments, like comments_articles.php and comments_videos.php and handle that like in the advanced tutorial, but I would actually prefer to have only a single comment template. How would I do that (in terms of the relations) or would you suggest to use several?

I had been thinking on the native comments not working with custom-routes and, I think (though not sure yet), that there can be a work-around this problem.

The only reason for the comments not working is that there is no 'page-view' available. In all probability only one of your routes (per template) would require comments so in a way that route is the page-view. Perhaps we can use a bit of PHP to force comments module into treating this route as such.

Can you grant me access to your site please? Allow me to test this postulate.

Hi Klaus,

Can you please try out the following proposed solution and let me know if it works?

Taking the example of the templates using in the advanced tutorial (, suppose we wish to attach comments to the 'page_view' route of 'notes.php'.

The first step, as per normal, is to declare the template as commentable -
<cms:template title='Notes' clonable='1' routable='1' commentable='1'>

Next, again as per normal, we need to place the code for showing the comments form and displaying the comments ( ... ments.html). This we do in the 'views/notes/page_view.html' snippet as this is the one handling the page-view.

The problem, as you have noticed, is that although the comment form displays fine, when we submit it Couch complains that this template is not commentable - this happens because commenting works only in native page-view (which we have seen is not applied by default when we make a template routable).

The proposed solution to this problem is this -
in the 'views/notes/page_view.html' snippet we are enforcing the page-view by explicitly fetching in the page (the 'rt_id' parameter) using cms:pages tag and then executing all code within its context -
<cms:pages id=rt_id limit='1' show_future_entries='1' >

<cms:set my_title=k_page_title 'global' />

<cms:capture into='my_content' >


<cms:embed 'views/layout_with_sidebar.html' />

We'll make a slight change to this arrangement. Instead of using the enclosing cms:pages tag block, we'll use the following instead -
global $PAGE, $CTX;

$CTX->set( 'k_is_home', 0 );
$PAGE = new KWebpage( '<cms:show k_template_name />', '<cms:show rt_id />' );

<cms:set my_title=k_page_title 'global' />

<cms:capture into='my_content' >

<cms:embed 'views/layout_with_sidebar.html' />

As you can see, we have removed the enclosing cms:pages bloack and instead thrown in a bit of PHP right at the top of the snippet to set the context to page-view.

The result should be the same for the original code in the snippet but, importantly, now the commenting should also work.

For documentation sake, if the snippet happened to use the 'page_name' (instead of page_id'), as you are doing, the PHP code above would become as follows (assuming 'rt_page_name' querystring parameter contains the page-name) -
global $PAGE, $CTX;

$CTX->set( 'k_is_home', 0 );
$PAGE = new KWebpage( '<cms:show k_template_name />', null, '<cms:show rt_page_name/>' );

Please try out and let me know if it helps.
Hello KK and all :) ,
I know this post is a year old but I am having the same issue with comments on custom routes.
I have tried the php solution you proposed above and I'm confused as to what to do with all my <cms:show xxx/> that come from the <cms:pages> tags.
Are all of them just going to be <cms:set.../> as global properties?

Also, when I do the php solution above I get a warning about the 'tags.php' in the admin folder.

"Parse error: syntax error, unexpected ')' in /.../admin/tags.php(2866) : eval()'d code on line 6"
which obviously can't be right.

I am using Couch v1.4.7 Has any more discussion come of this issue? I don't see anything else through the forums.

Thanks for any help that can be provided from anyone on this matter.
Did you try comments in a separate template? Let's do it.

Let's say, you have is as comments.php It is a normal default one, non-routable.

Then some created single cloned page of this template can hold comments for different routable templates or routable pages.
<cms:pages masterpage='comments.php' page_name='comments-for-routable' >

.. here we have k_is_page context and can show comments_form form for comments..


Now the same approach to list comments.
<cms:pages masterpage='comments.php' page_name='comments-for-routable' >

..again we have here page context and can fetch comments for it..

<cms:comments page_id=k_page_id >
<p><cms:show k_comment_author />:</p>
<p><cms:show k_comment /></p>


What you think?
Thank you Trendoman for taking the time to respond to my query. I appreciate your input.
I am confused on points of your solution though.

Then some created single cloned page of this template can hold comments for different routable templates or routable pages.

For clarity sake, let's just say I have this on a page on my blog. So my blog's 'page-view' holds the comment listing and input form. Normally done with an embed (<cms:embed 'comment-form.php' />, as of now, isn't compatible with custom routes

However, your solution says everything will now be shown via the <cms:pages ... ></cms:pages> tags.

But I'm not sure what editables will be in the template. The form itself uses inputs which are filled out on the front-end of the website.

Also, will this solution work with the moderation process, the anti-spam process? I'm trying to work with this template in different ways but haven't yet been successful.
11 posts Page 1 of 2

Who is online

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

Users browsing this forum: ianhaney50 and 24 guests