UPDATES EasySocial Native App v2.2 Released! More goodies and refinements!


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.

$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');
$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

Your time
Stack Ideas HQ
Support is

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!

Buy Us Coffee

Are you happy with our support and would like to buy us a cup of coffee?

Enjoy the Coffee!
Service via PayPal
Subscribe for product updates & promotions