Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hey I've recently attempted to add the function to comment on my current Couch CMS blog but keep getting the "Comments not allowed" error.

The blog is setup is 2 files: blog.php and blog-entry.php. blog-entry.php is Couch CMS cloneable and commentable template with 1 editable richtext field. blog.php lists the blog entries using blog-entry.php as a masterpage and under each entry I have used "<cms:if k_is_commentable >" followed by a simplified Couch CMS commenting form. I've tested the form showing and hiding when I make "commentable='1'" and "commentable='0'" which works good but even when "commentable='1'" and the blog post is set to allow comments in the admin panel by default I cannot comment.

Here is those 2 files for your reference:

blog.php
Code: Select all
<?php
   ob_start();
   session_start();
   
   require_once('couch/cms.php');
?>

<cms:template title='Blog' order='60'/>

<!DOCTYPE html>
<html lang='en'>
   <head>
      <title><cms:get_custom_field 'sitename' masterpage='globals.php' /> - <cms:get_custom_field 'sitetitle' masterpage='globals.php' /></title>
      <?php include('incs/head.php'); ?>
   </head>
   <body id='blog'>
      <div class='scroll clickable' id='up'>u</div>
      <div id='closemenu' class='clickable hide'>x</div>
      <div id='menuoverlay' class='table hide'>
         <div class='tablecell'>
            <?php include('incs/nav.php'); ?>
         </div>
      </div>
      <a href='/index.php' id='logo'>
         <img src='/img/logo.svg'>
      </a>
      <div class='wrapper'>
         <?php include('incs/top.php'); ?>
         <div id='contentbox'>
            <?php include('incs/header.php'); ?>
            <?php include('incs/banner.php'); ?>
            <?php include('incs/nav.php'); ?>
            <main>
               <cms:editable name='blogbody' label='Body text' type='richtext'>
                  <h1>Blog</h1>
               </cms:editable>
               <cms:pages masterpage='incs/blog-entry.php' limit='4' paginate='1'>
                  <div class='panel'>
                     <h2><cms:show k_page_title/></h2>
                     <h3><cms:date k_page_date format='jS M, Y'/></h3>
                     <cms:show blog />
                     <cms:if k_is_commentable >
                        <h3>Post a comment</h3>
                        <cms:form method="post" class="k_form">
                           <cms:if k_success >
                              <cms:process_comment />
                              <cms:if k_process_comment_success>
                                 <cms:send_mail from=k_email_from to=k_email_to subject='Comment posted'>
                                    The following comment has been posted at your site:
                                    <cms:show k_success />
                                 </cms:send_mail>
                                 <div class="k_successmessage">
                                    <p>
                                       Thank you for your comment. Your comment will be published as soon as it's reviewed by the Admin.
                                    </p>
                                 </div>
                              <cms:else />
                                 <div class="k_errormessage">
                                    <p>
                                       Could not post comment! The following error occured while processing your comment: <cms:show k_process_comment_error />
                                    </p>
                                 </div>
                              </cms:if>
                           <cms:else />
                              <cms:if k_error >
                                 <div class="k_errormessage">
                                    <p>
                                       Could not post comment! The form is incomplete.
                                    </p>
                                 </div>
                              </cms:if>
                              <cms:if k_logged_out >
                                 <cms:input type="text" name="k_author" tabindex="1" required="1"/>
                                 <cms:input type="text" name="k_email" tabindex="2" validator="email" required="1"/>
                                 <input type="text" name="k_link" tabindex="3" />
                              <cms:else />
                                 <p>
                                    Logged in as <b><cms:show k_user_title /></b>.
                                 </p>
                              </cms:if>
                              <cms:input type="textarea" name="k_comment" tabindex="4" validator_msg="required=Please enter a comment" required="1" />
                              <cms:input type="submit" class='clickable' value="Post comment" name="submit"/>
                           </cms:if>
                        </cms:form>
                     </cms:if>
                  </div>
                  <cms:paginator simple='1' prev_text='&#171; Newer' next_text='Older &#187;'/>
               </cms:pages>
            </main>
            <div class='clear'></div>
         </div>
      </div>
      <?php include('incs/footer.php'); ?>
   </body>
</html>

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


And here's blog-entry.php:
Code: Select all
<?php
   require_once('../couch/cms.php');
?>

<cms:template title='Blog Posts' clonable='1' order='61' commentable='0'>
   <cms:editable name='blog' label='Body text' type='richtext'>
      <p>
         This text is being used as a placeholder for information and images. This text is being used as a placeholder for information and images. This text is being used as a placeholder for information and images.
      </p>
   </cms:editable>
</cms:template>

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


Appreciate any help of ideas here, I've put a days troubleshooting into it so I'm pretty stumped. Next step is to try and recreate the blog to see where I've gone wrong lol.
Hi,

The comment processing code actually posts the comments to the actual template being visited - in your case it would be 'blog.php' which happens to be non-clonable and non-commentable. Ergo the error message.

That said, I am not sure why you needed to use two separate templates for your blog.
My advice to you would be to use only a single template instead of two. The 'blog.php' is the most natural candidate. Make it clonable, commentable and define in it all regions currently defined in 'blog-entry.php'.

The 'blog-entry.php' template can be removed.
This, however, will cause data loss as all the current cloned pages of this template will be deleted.

So, in case you already have a lot of data that cannot be recreated, another way would be to 'rename' blog-entry.php to blog.php (while deleting the original blog.php).
This will require some due care - please search the forum for renaming templates and you'll find a couple of posts discussing this.

Hope it helps.
Thanks KK, I don't mind losing any of the blog content so i've added the content from blog-entry.php to the top of blog.php and made a few changes similar to the "blog.php" file Couch CMS has provided for the tutorial. Now I just have the 1 blog page with the following code:
Code: Select all
<?php
   ob_start();
   session_start();
   
   require_once('couch/cms.php');
?>

<cms:template title='Blog Posts' clonable='1' order='61' commentable='1'>
   <cms:editable name='blog_content' label='Body text' type='richtext'>
      <p>
         This text is being used as a placeholder for information and images. This text is being used as a placeholder for information and images. This text is being used as a placeholder for information and images.
      </p>
   </cms:editable>
</cms:template>

<cms:if k_is_page >
   <!DOCTYPE html>
   <html lang='en'>
      <head>
         <title><cms:get_custom_field 'sitename' masterpage='globals.php' /> - <cms:get_custom_field 'sitetitle' masterpage='globals.php' /></title>
         <?php include('incs/head.php'); ?>
      </head>
      <body id='blog'>
         <div class='scroll clickable' id='up'>u</div>
         <div id='closemenu' class='clickable hide'>x</div>
         <div id='menuoverlay' class='table hide'>
            <div class='tablecell'>
               <?php include('incs/nav.php'); ?>
            </div>
         </div>
         <a href='/index.php' id='logo'>
            <img src='/img/logo.svg'>
         </a>
         <div class='wrapper'>
            <?php include('incs/top.php'); ?>
            <div id='contentbox'>
               <?php include('incs/header.php'); ?>
               <?php include('incs/banner.php'); ?>
               <?php include('incs/nav.php'); ?>
               <main>
                  <div class='panel'>
                     <cms:show blog_content />
                  </div>
               </main>
               <div class='clear'></div>
            </div>
         </div>
         <?php include('incs/footer.php'); ?>
      </body>
   </html>
<cms:else />
   Nothing.
</cms:if>

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


Now the "<cms:if k_is_page >" doesn't seem to come up as true as I only see "Nothing." I can however, add blogs in the Admin panel. I've tried removing the "<cms:if k_is_page >" block and the page works but doesn't "<cms:show blog_content />" shows nothing.
In the admin-panel where you see a list of all the blog cloned-pages, you'll find a 'magnifying glass' icon next to the pages.
Click any of those to reach the page-view.

On the front-end template, in the list-view (that currently shows 'nothing'), you'll need to use <cms:pages> to create such a listing linking to the cloned-pages.

Hope it helps.
Thanks KK that works great, originally I wanted multiple blog posts and comments on a single page but it makes more sense having separate pages like this.
5 posts Page 1 of 1