Last active
December 1, 2021 00:35
-
-
Save hissy/2de1d8710dc861e5681378c477b30198 to your computer and use it in GitHub Desktop.
#ConcreteCMS Get conversation messages count by Page object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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