Comments

NEWS & TIPS

  • Site Access Keys
  • Top: Alt+t
    Previous: Alt+,
    Next: Alt+.
    Up: Alt+;
    (Note: use Ctrl on the Mac)

Page/Blog Comments

Author: John Stokely

1. Introduction

The purpose of this code is to provide the ability for users on a live website to comment on the page or blog posting. 

This guide will quickly walk you through installing and configuring a custom php comment system on your site. It assumes that you have a recent version of PHP installed on your web server and that you are comfortable with Cascade. Knowledge of PHP is also useful, but not necessary to use this guide.

2. Components

There are several components to the comment system including the display comment block, the comment script itself, and the configuration page. The script will read its configuration from a configuration file that you will publish (with the use of a data definition), search and modify the XML data file, and display the results to user.

3. The Configuration Page

To edit the configuration of the comment script, go to /intranet/cast/comment-config.xml.  The output file for comments is where all comment data will be stored.  This should be a file that was previously used for this comment system, or a file that does not currently exist.  The "comment page" asset should point to /intranet/cast/postComment.php, and the "delete comment page" asset should point to /intranet/cast/deleteComment.php.  Now for the less obvious sections:
    a. Page layout:
        This is a wysiwyg editor that lets you determine how each comment will appear on the page.  The only
        modification that is made to this during run-time is the #comment field will be replaced by the
        current comment, the #add field will be replaced by the add button, and the #delete field will
        be replaced by the delete button.
    b. Global opening divider:
        This is a text field that takes in html, and inserts it at the top of the comment section on
        each page that has comments enabled on it.  This is not a full wysiwyg editor, so that you can
        open tags in this field without closing them
    c. Global closing divider:
        This is a text field that takes in html, and inserts it at the bottom of the comment section
        on each page that has comments enabled on it.  This is not a full wysiwyg editor, so you can close
        tags here that were opened in the Global opening divider.
    d. Local opening divider:
        This is a text field that takes in html, and inserts it at the top of each user comment.  This
        is not a full wysiwyg editor, so that you can open tags in this field without closing them
    e. Local closing divider:
        This is a text field that takes in html, and inserts it at the bottom of each user comment.  This
        is not a full wysiwyg editor, so that you can close tags in this field that were opened in
        the Local opening divider.
    f. Add/Delete button attributes:
        These are text fields that take in html attributes, and insert them into the button declaration
        for the add and delete buttons, respectively.  These can be modified to give the buttons any
        margins, colors, etc.  This text will be inserted in the form of: <form #attributes>, with
        #attributes being the text supplied in these fields.

4. The Data Synchronizer

To Synchronize all comments on your publish server with your CMS, run comment-data-synchronizer.php.  Note: For this to work, your configuration page must have valid login information as well as a valid server location

5. The Comment Viewer

To view all comments that have been made on your page, first run the data synchronizer.  This will ensure that you are seeing the most recent version of the comments.  Once you have done this, open comment-view.  This will show you all comments that have been made on all pages in your system.

6. Usage

To use the script, publish the page and file assets.  Then put the displayComment block into the page that you want to be able to comment in.  Publish this page, and comments will be enabled on it.  If you want to change the layout of the comments on the page, modify and re-publish the configuration page.

Comment Files

  1. comment-config-xml-php.txt
    The XML config file used by the comments code.
  2. comment-config-data-definition.xml
    The data definition code used to produce the config XML.
  3. comment-config-data-definition.xsl
    The XSL to transform the XML from the data definition into the config XML.
  4. comment-data-xml-php.txt
    Example XML data file that stores user comments.
  5. comment-data-synchronizer-php.txt
    This script backups the XML comments file on a regular basis with the CMS via web services.
  6. comment-view.xsl
    This XSL makes the XML comments backup file suitable for viewing in the CMS.
  7. deleteComment-php.txt
    This script allows a user to delete a comment.
  8. displayComment-php.txt
    This is the main script to include with a page to provide the commenting option on the live site.
  9. postComment-php.txt
    This code processes the user's comment post.
  10. variables-php.txt
    This script reads the XML config file and loads the appropriate variables.
  11. comments-PHP.zip
    ZIP containing all of the files necessary for the item to work with PHP.
Last modified on Tue, 11 Sep 2007 14:52:45 -0400

Top / Up / Table of Contents