Comment Plugin - error in displaying user name

23 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 10, 2014   (RSS)

By claire - June 9, 2014

Can you send me the code for the comment uniqueness issue? I'll see if anything jumps out.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By meg - June 9, 2014

Something like this?

 list($_wsc_commentsRecords, $_wsc_commentsMetaData) = getRecords(array(
    'tableName'   => '_wsc_comments',
    'loadUploads' => true,
    'allowSearch' => false,
    'where'       => whereRecordNumberInUrl(1),
  ));

By claire - June 9, 2014

Yeah, that's the idea, but I don't think it'll work in your case unless you can put the article ID number into the URL.

How are you generating the individual article links right now?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By meg - June 10, 2014

This is the php for generating the article: 

list($questionsRecords, $questionsMetaData) = getRecords(array(
    'tableName'   => 'questions',
    'where'       => whereRecordNumberInUrl(1), // If no record # is specified then latest record is shown
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $detailRecord = @$questionsRecords[0]

In the view URL's, the detail page is /article.php and I'm using the field name "question" to generate the article name. So, for example, it would generate the URL: article.php?Question-About-Life-1

So, how exactly do I make the comments unique to an individual article page? I'm a little confused now...

By claire - June 10, 2014

Okay, here's how it should work:

You've got the actual article information in $detailRecord, right? This should include the article ID number. What you need to do is then give the article ID to the function that gets the comments, so it filters out all but the comments you want.

It'd look something like this:

list($_wsc_commentsRecords, $_wsc_commentsMetaData) = getRecords(array(
    'tableName'   => '_wsc_comments',
    'loadUploads' => true,
    'allowSearch' => false,
    'where'       => 'article_id = ' . $detailRecord['num'],
  ));

You'd want to replace 'article_id' and '$detailRecord['num']' with whatever you've named those variables in the Section editor.

Does this make sense?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By meg - June 10, 2014

So if the detail article page is this: 

list($questionsRecords, $questionsMetaData) = getRecords(array(
    'tableName'   => 'questions',
    'where'       => whereRecordNumberInUrl(1), // If no record # is specified then latest record is shown
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $detailRecord = @$questionsRecords[0]

the comments should be this?

list($_wsc_commentsRecords, $_wsc_commentsMetaData) = getRecords(array(
    'tableName'   => '_wsc_comments',
    'loadUploads' => true,
    'allowSearch' => false,
    'where'       => 'article_id = ' . $questionsRecords['num'],
  ));

I'm a little confused on what the article_id should be...

By claire - June 10, 2014

The article_id is whatever reference exists in the comment record for the article that it's supposed to go with, which I'm assuming is called something like article_id or articleNum.

Can you list the fields associated with the comment records? It's probably pretty obvious, or at least I hope it is.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By meg - June 10, 2014

Comment fields in the Section Editor:

comment

attachments

tableOrTag

recordNum

num

createdDate

createdByUserNum

By claire - June 10, 2014

Alright then, try this:

list($_wsc_commentsRecords, $_wsc_commentsMetaData) = getRecords(array(
    'tableName'   => '_wsc_comments',
    'loadUploads' => true,
    'allowSearch' => false,
    'where'       => 'recordNum = ' . $questionsRecords['num'],
  ));

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/