Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active December 1, 2021 00:35
Show Gist options
  • Save hissy/2de1d8710dc861e5681378c477b30198 to your computer and use it in GitHub Desktop.
Save hissy/2de1d8710dc861e5681378c477b30198 to your computer and use it in GitHub Desktop.
#ConcreteCMS Get conversation messages count by Page object
<?php
/** @var \Concrete\Core\Page\Page $page */
$totalMessages = 0;
foreach ($page->getBlocks() as $block) {
if ($block->getBlockTypeHandle() === 'core_conversation') {
/** @var \Concrete\Core\Conversation\Conversation $conversation */
$conversation = $block->getController()->getConversationObject();
if ($conversation) {
$totalMessages = $conversation->getConversationMessagesTotal();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment