Conversations

Improvements?

Let us know by posting here.

Conversations

Conversations are general objects that automatically get created for each new instance of the conversation block on a page. (Note: this is different than 5.6's Guestbook block, which bound messages directly to an instance of the block.).

Messages belong to a conversation, and can be listed in the dashboard.

Discussion objects can group Conversation objects.

Conversation RatingType objects can be installed and allow developers to influence a message's score. RatingType examples include "up_vote" and "down_vote."

Conversation Editors are different ways to present message posting to users. Examples of editors include the "Redactor Rich Text Editor", "Plain Text", "BBCode", "Markdown" and more.

Conversation FlagType objects are similar to RatingType objects, but handle flagging messages for moderation or removal. An example of a flag type is "spam".

Example Code

Below is an example of how to fetch the latest messages for a site and retrieve various details about each.

// Retrieve a list of 20 latest comments/messages
$messageList = new \Concrete\Core\Conversation\Message\MessageList();
$messageList->filterByApproved();
$messageList->sortByDateDescending();
$messages = $messageList->get(20);

foreach ($messages as $message) {

    // Find the page that this message was posted to
    $page = \Concrete\Core\Page\Page::getByID($message->getConversationObject()->cID);

    // Skip message if coming from a trashed/draft page
    if (!$page->getVersionObject()->cvIsApproved)
        continue;

    // Find the user who posted this message            
    $messageAuthor = $message->cnvMessageAuthor->getUser();

    // Skip message if coming from a deleted user
    if (!$messageAuthor)
        continue;

    // Find the name of the page that was commented on
    $pageName = $page->getCollectionName();

    // Find the URL of the page
    $link = \URL::to($page);

    // Find the timestamp of when message was posted
    $timestamp = strtotime($message->cnvMessageDateCreated);

    // Find the full name of the message author
    $authorFullName = $messageAuthor->getAttribute('first_name') . ' ' . $messageAuthor->getAttribute('last_name');

}