Conversations List
Permalink
I have been playing with Conversations a little and I am looking for a way to get the Conversations for a particular pages. It looks like I can get all the Conversations with:
I haven't found a way to filter those by a particular page (like you could if you were working with the page list).
Can anyone give me the correct way to get conversations for a particular page?
Thanks
$ml = new MessageList(); $messages = $ml->get();
I haven't found a way to filter those by a particular page (like you could if you were working with the page list).
Can anyone give me the correct way to get conversations for a particular page?
Thanks
bump.. Anyone have any help on retrieving just the conversations for a given page?
Hey so so. Was pulling my hair out about this one too. Took a little bit but figured this out by looking through the controller. Essentially first I got the block ID then made a DB query. Here is the code. Hope it helps someone out later. (Maybe me :-) )
Maybe there's an easier way. But it's all I've found.
<?php $page = Page::getCurrentPage(); $blocks = $page->getBlocks('Comment'); // getblocks by area. You could probably get all the blocks from the page. if($blocks) { foreach ($blocks as $block) { $handle = $block->getBlockTypeHandle(); if ($handle == 'core_conversation') { //check to see if this is a conversation block. $blockID = $block->getBlockID(); //If you have > 1 you may have to iterate over an array later on. } } } $db = Database::get(); $cnvID = $db->GetOne('select cnvID from btCoreConversation where bID = ?', $blockID); // this is where the magic happens. $conversation = Conversation::getByID($cnvID); $messageList = new \Concrete\Core\Conversation\Message\MessageList();
Viewing 15 lines of 20 lines. View entire code block.
Maybe there's an easier way. But it's all I've found.
For 5.7:http://documentation.concrete5.org/developers/concepts/conversation...
http://documentation.concrete5.org/api/class-Concrete.Core.Conversa...
But you have to make some changes:
Change:
Add:
Remove:
And echo what you want to show.
http://documentation.concrete5.org/api/class-Concrete.Core.Conversa...
But you have to make some changes:
Change:
$messageAuthor = $message->cnvMessageAuthor->getName(); $dh = Core::make('helper/date'); $timestamp = strtotime($message->getConversationMessageDateTime()); $timestamp = $dh->formatCustom('d M Y - H:i:s', $timestamp);
Add:
$messageBody = $message->getConversationMessageBody();
Remove:
//$authorFullName = $messageAuthor->getAttribute('first_name') . ' ' . $messageAuthor->getAttribute('last_name');
And echo what you want to show.