Website Comments - getRecords

4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 28, 2012   (RSS)

By Perchpole - May 26, 2012

Hello, All -

I've just set-up Website Comments on my system and I really very impressed with what it can do! I think I've got everything in place but I just wanted to know a couple of things...

Can I run a getRecords call to list the comments? Currently I'm using a MySQL query to pull in the comments but I need to JOIN this with the cms_accounts table to get the userNames, etc.

When I look at the new WSC tables via phpMyAdmin they appear to be nested inside a table called CMS. Is this normal?

I also notice there is a double underscore in the table names, eg:

cms__wsc_comments

Again, is this normal?

Otherwise, money well spent on a fantastic plugin!

:0)

Perchpole

Re: [Perchpole] Website Comments - getRecords

By Dave - May 27, 2012

Hi Perch,

Glad to hear you are liking the plugin! :) Here's some answers to your questions (and some extra background info you may find helpful).

>Can I run a getRecords call to list the comments?

The standard way to list comments is with the wsc_comments() function call (see the readme.txt and the plugin examples). The output displayed for comments can be modified in plugins/websiteComments/themes/default.php

It actually already loads all the details about the user who created each comment, so if you wanted to display the comment creators fullname for example you could use: <?php echo $comment['createdBy.fullname'] ?>.

This is actually an undocumented feature of getRecords(), anytime there is a createdByUserNum field it loads that record and adds all those fields with the "createdBy." prefix. Note that the fields are not loaded with a join so you can search or sort on them.

We have a utility function called showme() that outputs all the variables in an array or record. So anytime you want to see what's available to you just add some temporary debug code: <?php showme($record); ?>.

Next, if you want to do a direct getRecords() call you can copy the code for that from wsc_comments_getRecords() in websiteComments.php or just call that function directly.

And lastly, the double underscore is intended. Many of the plugins need to create their own tables, but we have no way of knowing which tables a user may have already created, so the CMS doesn't allow you to create tables that start with an underscore and the plugins all use tables that start with an underscore so there is no chance of a collision.

Hope that helps! Let me know any questions.
Dave Edis - Senior Developer
interactivetools.com

Re: [Perchpole] Website Comments - getRecords

By Dave - May 28, 2012

Great, glad to hear you've got it working that way you need. :)
Dave Edis - Senior Developer
interactivetools.com