Keyword

number of articles

  • Sebastian Kalak
  • Sebastian Kalak's Avatar Topic Author
  • Offline
  • New Member
More
4 months 2 weeks ago #181339 by Sebastian Kalak
number of articles was created by Sebastian Kalak
Is there no option on the user's page (blog) to display the number of articles added by the user? Is there an option to upgrade with this feature?

Please Log in or Create an account to join the conversation.

More
4 months 1 day ago #181375 by JoomlaWorks
Replied by JoomlaWorks on topic number of articles
No, sorry. You can write a snippet to query the DB and just count the items written by this user. This could even be done on the user sub-template.
<?php
/**
 * Display the number of items published by the current user.
 *
 * @param   int  $userId  The user ID.
 * @return  string
 */

function k2_user_items_count($userId) {
    $db = JFactory::getDbo();
    $db->query('COUNT(*) FROM #__k2_items WHERE created_by = '.$userId);
    $db->setQuery($query);
    $numItems = $db->loadResult();
    return $numItems;
}

// Get the current user ID
$userId = (int) JFactory::getUser()->id;

// Count the number of items published by the current user
$numItems = k2_user_items_count($userId);

// Display the number of items
echo '<span>' . $numItems . '</span>';

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum