EasySocial 2.2.6
Sometimes you need to display total blog post count "outside" EasyBlog component, in a custom template position.
You can do this by using the code below. The code will query the database and will display the total published blog posts count for current logged-in user.


<?php
$user =JFactory::getUser();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = 'select count(1) as `post_count`';
$query .= ' from `#__easyblog_post` as a';
$query .= ' where a.`created_by` = ' . $user->id;
$query .= ' and a.published = ' . $db->Quote('1');
$db->setQuery($query);
$postcount = $db->loadResult();
echo $postcount;
?>


You can use this if you want for example to present to the current logged-in user his total blog posts count. Think about it kinda like a "notification" count. In our case scenario, we built a "My Account" custom menu where we listed some personal menu option for current logged in user. We used the above code to show post count next to "My Blog Posts" menu option.

Enjoy ! I hope you will find a good use ! :p

This section can only be seen by users with a valid subscription.
If you have a valid subscription, please login now

Support is
Offline

It is currently off working hours and most of us aren't around.

Rest assured that we will get back to your issues as soon as the day starts tomorrow!

Your time
Stack Ideas time