Search the Blog Minimize
spacer
DNNDev Blogs: Most recent blog entries Minimize

Free XMod Comment Approval Tool

Oct 19

Written by:
10/19/2009 11:49 AM  RssIcon

 Have you ever needed a method to check all of your Xmod listings for added unapproved comments?

I know I have. Here is how I did it...

Have you ever needed a method to check all of your XMod listings for added unapproved comments?

I know I have.

Unfortunately the current comment portion of XMod form code does not send an email notifying you that a comment is requiring approval.

It has always been a painstaking task to traverse through all listings to approve new unapproved comments.

The solution was to create a XMod form that has the capability to view unapproved comments and then link to the listing to complete the approval process.

Here is how I did it.

Step 1.

While logged into my DotNetNuke site as the Host account, I go to Host >> SQL and run the following select statement.

Note: Leave the Run As Script box unchecked.

SELECT FormName,FormId 
FROM KB_XMod_Forms

XMod Forms SQL FormId

Records will be returned for all of the XMod forms on your portal.

Select the form that you want to monitor unapproved comments and jot down the FormId number.

You will need this number to set the form parameter named FormId later in this lesson.

Step 2.

Create a new page on your site and set the permissions that only the Administrator can view the page.

I create a comment approval page for each of our DNN Professor applications. In this example I will name this page Directory Comment Approval and place this page directly below the listing page for our Business Directory main page.

After the page has been created I will jot down the URL for the page in Notepad.

In this example it would be http://yoursite.com/DNNDirectory/DirectoryCommentApproval.aspx

You will need this page URL to set the form parameter named SearchURL later in this lesson.

Step 3.

Add a Xmod FormView module to this page.

Add XMod FormView Module

Step 4.

In the Xmod module action menu go to >> Manage Forms

Add XMod Form

Create a new form.

In our example I will name this form DNNP-BD6.1 Comment Approval Form.

On the setting link select Custom HTML-Based Layout and for Item Approval select Auto Approve All Records.

In the editor window we will add the following code:

<form format="custom"> 
  <parameters> 
    <!-- Replace this parameter default value if you have created a DNN database object qualifier prefix - default is .dbo--> 
    <parameter name="DBobjectQualifier" alias="DBobjQual" default="dbo."> 
    </parameter> 
    <parameter name="charactersReturned" alias="cReturn" default="150"> 
    </parameter> 
    <parameter name="FormId" alias="FormId" default="YOUR FORM ID NUMBER"> 
    </parameter> 
    <!--Replace this parameter default value with the full URL of your Comment approval form page-->
    <parameter name="SearchURL" alias="SearchURL" default="YOUR COMMENT APPROVAL PAGE"> 
    </parameter> 
    <!--Replace this parameter with the full URL of your main form listings page--> 
    <parameter name="redirURL" alias="redirURL" default="YOUR LISTING PAGE URL"> 
    </parameter> 
    <parameter name="SearchType" alias="SearchType" default=""> 
    </parameter> 
    <parameter name="selComment" alias="selComment" default=""> 
    </parameter> 
    <parameter name="c1loc1" alias="c1loc1" default=""> 
    </parameter> 
    <parameter name="c1" alias="c1" default=""> 
    </parameter> 
    <parameter name="LocType" alias="LocType" default=""> 
    </parameter> 
  </parameters> 
  <controls> 
    <scriptblock scriptid="FilterJS" blocktype="HeadScript" registeronce="true"> 
      <script type="text/javascript"> 
        <!-- 
// Script  - copyright Buck Anderson and DNNprofessor.com 

function getComment(retComment) { 
var CommentIndex = document.getElementById(XModForm{XMOD_ModuleId}.cboCommentLookup).selectedIndex 
document.getElementById('searchComments').style.display = 'none'; 
  if (retComment == "") 
    return; 
  location.href = "{SearchURL}" + "?selComment=" + retComment + "&c1loc1=" + CommentIndex + "&SearchType=1"; 
} 
//--> 
      </script> 
    </scriptblock> 
    <div id="SearchCommentDiv"> 
      <h2>Select Comments</h2> 
      <p class="dnnpNormal"> 
        <strong>Search by Unapproved Comments:</strong> 
      </p> 
      <select1 ref="cboCommentLookup" appearance="minimal" query="SELECT LEFT(comment, {cReturn}) + '...', XModID 
FROM {DBobjQual}KB_XMod_Comments t1 WHERE (FormID = {FormId}) AND (Approved = 0) OR (Approved IS NULL)
ORDER BY t1.DatePosted DESC" class="dnnpNormalTextBox" onchange="getComment(this.value)"> <label class="dnnpNormal">Comments</label> <items> <item> <label>-Select-</label> <value> </value> </item> </items> </select1> <span id="searchComments" class="Normal"> <a href="{redirURL}?xmid={selComment}">Click to Edit Comment</a></span> </div> <addbutton text="" /> <cancelbutton text="" /> <script language="javascript" type="text/javascript"> initializeForm(); </script> <scriptblock scriptid="InitializeScripts" registeronce="true"> <script language="JavaScript" type="text/javascript"> <!-- // Script - copyright DNNprofessor.com function initializeForm(){ //document.getElementById('searchComments').style.display = 'none'; var hasComment = "{selComment}"; var CommentIndex = "{c1loc1}"; if (CommentIndex != "") { document.getElementById(XModForm{XMOD_ModuleId}.cboCommentLookup).options[CommentIndex].selected =true; } if (hasComment == "") { document.getElementById('searchComments').style.display = 'none'; } else { document.getElementById('searchComments').style.display = ''; } } //--> </script> </scriptblock> </controls> </form>

Before we save the form we need to change form parameters to match our portal.

<!-- Replace this parameter default value if you have created a DNN database object qualifier prefix - default is .dbo--> 
    <parameter name="DBobjectQualifier" alias="DBobjQual" default="dbo.">

In most cases, this parameter can be left at the default, .dbo. If you had added an object Qualifier to your DNN portal during the setup installation wizard you would append this parameter value with your object qualifier to ensure that the SQL select statement will run correctly.

Example:

If our site has an object qualifier named portal2_ our parameter value would be:

<parameter name="DBobjectQualifier" alias="DBobjQual" default="dbo.portal2_">

The next parameter change would be to add the FormId of your Xmod form that will be atrtached to this comment instance.

<parameter name="FormId" alias="FormId" default="YOUR FORM ID NUMBER"> 

In our example the results returned from step 1 indicated that our FormId was 3 and we will replace the default FormId parameter value, YOUR FORM ID NUMBER with the FormId 3.

<parameter name="FormId" alias="FormId" default="3">

The next parameter change would be to allow the code to return to the comment approval page.

<!--Replace this parameter default value with the full URL of your Comment approval form page-->   

<parameter name="SearchURL" alias="SearchURL" default="YOUR COMMENT APPROVAL PAGE">

You will replace the value, YOUR COMMENT APPROVAL PAGE, with the URL of your comment approval page that you created in step 2.

In our example:

<parameter name="SearchURL" alias="SearchURL" default="http://dnnprofessor.com/DNNDirectory/DirectoryCommentApproval.aspx">

The next parameter change would be to allow the form code result to return to the XMod listings page page.

<!--Replace this parameter with the full URL of your main form listings page--> 

<parameter name="redirURL" alias="redirURL" default="YOUR LISTING PAGE URL"> 

You will replace the value, "YOUR LISTING PAGE URL, with the URL of your page that contains the Xmod instance and shows your listings.

In our example:

<parameter name="SearchURL" alias="SearchURL" default="http://dnnprofessor.com/DNNDirectory.aspx">

After you have completed the parameter changes simply save the form.

Step 5.

Configure your Xmod FormView module to use the created form.

You are now ready to view any unapproved comments for the assigned form instance.

Helpful Tips:

Tip 1.

I noticed that comment length became rather long and does not wrap in a XMod Select1 form field.

This caused my comment approval page to be too wide when the results were returned.

Since I didn't really need to see the entire comment to get some idea of its contents, I added a truncate routine to the SQL query attached to the Select1 form field.

In the form code above, I set character truncation to 150 in the form parameter named, charactersReturned.

<parameter name="charactersReturned" alias="cReturn" default="150">

You can modify this parameter to suit your own needs.

Tip 2.

Prior to Xmod 5.5.1 only the Host account could approve or unapprove comments. I addressed this issue with Kelly Ford, developer of XMod, and version 5.5.1 or higher now allows the primary site Administrator to approve and unapprove comments.

And that's all that is needed to set up unapproved comment viewing.

My daily routine now consists of periodically viewing the Directory Comment Approval for any unapproved comments.

Select Comment

Approve Comment

Enjoy,
Buck

Copyright ©2009 Buck Anderson and DNNprofessor.com

Tags:
Categories:
Location: Blogs Parent Separator Buck Anderson

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 
spacer
dummy