Hi,
I'm trying to add a 'conversations' item to the sidebar. It should work similarly to the conversations icon in the toolbar. It should show notifications when a new message comes in.
Here's what I have done so far:
I have used a template override to modify the dashboard layout, overriding dashboard/default.php. In the dashboard override I use the following code snippet to pull in a custom template I created called 'messages':
echo $this->includeTemplate( 'site/dashboard/messages' );
The messages template basically looks like this:
<?php
$my = Foundry::user();
if( $my->id )
{
// Get a list of new conversations
$newConversations = $my->getTotalNewConversations();
}
?>
<div class="es-widget es-widget-borderless">
<div class="es-widget-head">
<div class="widget-title pull-left">
<?php echo JText::_( 'Messages' );?>
</div>
</div>
<?php echo $this->loadTemplate( 'site/toolbar/default.conversations' , array( 'newConversations' => $newConversations ) ); ?>
</div>
This pulls in the 'site/toolbar/default.conversations' template and gives a value to the $newConversations variable, which is the number of new messages received. This is shown on the front-end as a red circle showing the number of new conversations. And this is where I have my problem...
So far I get the new conversations count to update correctly on page load. However, when a new conversation comes in after page load, the counter doesn't update like the one in the toolbar does. I was hoping that pulling in the 'site/toolbar/default.conversations' template, which is the same one used in the toolbar, would cause the required JavaScript to work. Is there a non-hackish way to accomplish this?
How do I get the conversations counter to update?