Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated

[SOLUTION] Add counter on Toolbar for Friends, Groups, Photos, Videos and Events

1 year 8 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

Hello Me module has neat feature that displays count for Friends, Groups, Photos, Videos and Events. Since Hello Me is redundant to me, but I do like those counters we can implement those in JS Toolbar or mod_community_bar. Don't forget to update override if some changes are made in original mod_community_bar. Don't do this if you are not comfortable with editing php since I cannot be blamed for any damage on your site.
This works only when names of Links in Toolbar are Friends, Groups, Photos, Videos and Events. For different name and language specific names changes are needed.
1) Make Joomla template override for module by copying :
...\modules\mod_community_bar\tmpl\default.php
to
...\templates\MY_JOOMLA_TEMAPLTE\html\mod_community_bar\default.php
2) On line 29 (after line "$newEventInviteCount += $newNotificationCount;") of new file insert:

    //video count
    $videoModel = CFactory::getModel('Videos');
    $totalVideos = $videoModel->getVideosCount($user->id);

    //photo count
    $photosModel = CFactory::getModel('photos');
    $totalPhotos = $photosModel->getPhotosCount($user->id);

    //group count
    $groupmodel = CFactory::getModel('groups');
    $totalGroups = $groupmodel->getGroupsCount($user->id);

    //event count
    $eventmodel = CFactory::getModel('events');
    $totalEvents = $eventmodel->getEventsCount($user->id);
3) On line 124 there should be line:
<?php if($moduleParams->get('navigationmenu')) { ?>
and after that block:
                <?php foreach ($navMenuItems as $item): ?>
                    <li><a href="<?php echo CRoute::_($item->link); ?>"><?php echo JText::_($item->title); ?></a></li>
                <?php endforeach; ?>
that needs to be replaced by:
                <?php 
				foreach ($navMenuItems as $item) { 
					switch ($item->title){
						case "Friends":
						echo '<li><a href="' . CRoute::_($item->link) . '">' . JText::_($item->title) . '<span class="counter"> ' . $user->_friendcount . '</span></a></li>';
						break;
						
						case "Groups":
						echo '<li><a href="' . CRoute::_($item->link) . '">' . JText::_($item->title) . '<span class="counter"> ' . $totalGroups . '</span></a></li>';
						break;
						
						case "Photos":
						echo '<li><a href="' . CRoute::_($item->link) . '">' . JText::_($item->title) . '<span class="counter"> ' . $totalPhotos . '</span></a></li>';
						break;
						
						case "Videos":
						echo '<li><a href="' . CRoute::_($item->link) . '">' . JText::_($item->title) . '<span class="counter"> ' . $totalVideos . '</span></a></li>';
						break;
						
						case "Events":
						echo '<li><a href="' . CRoute::_($item->link) . '">' . JText::_($item->title) . '<span class="counter"> ' . $totalEvents . '</span></a></li>';
						break;
						
						default:
						echo '<li><a href="' . CRoute::_($item->link) . '">' . JText::_($item->title) . '</a></li>';
						break;
					}
				}
				?>
In case of different names for some links or language specific names, code needs to be changed like:
...
case "Amici":
case "Друзья":
case "Freunde":
case "Friends":
echo '<li><a href="' . CRoute::_($item->link) . '">' . JText::_($item->title) . '<span> ' . $user->_friendcount . '</span></a></li>';
break;
...
Implementing language specific names needs more coding and implementing language constants/values.
4) Some css is needed to style new span:
.joms-toolbar--desktop > ul > li > a > span.counter {
	opacity: 0.5;
}

The following user(s) said Thank You: Danny
1 year 8 months ago
  • Dimas's Avatar
  • Dimas
  • Visitor
  • Thank you received: 0
Licenses:

Hi,

Thank you for sharing we appreciate it.. please you also share this topic on our community group www.jomsocial.com/community/groups/viewg...omsocial-tips-tricks

thank you!

1 year 8 months ago
Licenses:
JomSocial Active

Can you please share screenshots (before and after)? Thanks.


Sorry for my English
1 year 8 months ago
  • Vladimir's Avatar
    Topic Author
  • Vladimir
  • Offline
  • Junior Boarder
  • Posts: 283
  • Thank you received: 40
Licenses:
JomSocial Active

Sure, this is my solution, but You have <span> element to style it to your own preferences.

Attachments:
The following user(s) said Thank You: Danny, Keld, Michał
1 year 8 months ago
Licenses:

+1 :)


- Instead of saying: 'it's not working', explain the problem in detail.
- Screenshots with the URL visible in them and the problem marked are more than welcome.
- Tell us how to replicate the problem, we can't fix it if we can't find it.
- Make sure that your site/server meets JomSocial System Requirements
- Make sure to setup JomSocial Cron Job
- Always provide us with access details to the backend and ftp. We need it to debug problems.
- If you have a similar problem, but a solution you found isn't working, open a new thread instead of 'merging' with an existing one.

- Use the "Thank You" feature on any post that helped you
The following user(s) said Thank You: Vladimir
Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW