By Ron Wade-Megghross on Wednesday, 11 March 2015
Posted in Technical Issues
Replies 1
Likes 0
Views 572
Votes 0
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?
Hello Ron,

We are actually using javascript to check the counter. You might want to follow our Easysocial Notification module in this file: ../modules/mod_easysocial_notifications/scripts/script.js. There you can see it check for new counter based on the interval. Or you can manually create your own script for the interval and get the conversation counter using function getConversationCounter() which you can find it in this file: ../components/com_easysocial/controllers/notifications.php. Hope this helps.
·
Wednesday, 11 March 2015 12:13
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post