Keyword

[SOLVED] module which displays a total count of items

More
10 years 1 month ago #125984 by Lefteris
You are welcome.

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

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

More
9 years 9 months ago #125985 by Chris Casconi
Replied by Chris Casconi on topic Re: module which displays a total count of items
I know this topic is solved, but is there a way to drill this down even further and make the article count for a specific category inside K2?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 9 months ago #125986 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: module which displays a total count of items
Sure you need to add the catid check in your query.
eg:
AND catid = 5
Where 5 is your category's id.

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

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

More
9 years 8 months ago #125987 by Chris Casconi
Replied by Chris Casconi on topic Re: module which displays a total count of items
Where in the code do I insert that?

<?php
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(*) FROM #__k2_categories WHERE published = 1 AND trash = 0");
$result = $db->loadResult();
?>

Where in the above code?

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

More
9 years 8 months ago #125988 by Chris Casconi
Replied by Chris Casconi on topic Re: module which displays a total count of items
I think I've got it worked out!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 8 months ago #125989 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: module which displays a total count of items
Nice to hear that.

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

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

  • Dennis Miliopoulos
  • Dennis Miliopoulos's Avatar
  • Offline
  • Junior Member
More
9 years 6 months ago #125990 by Dennis Miliopoulos
Replied by Dennis Miliopoulos on topic Re: module which displays a total count of items
Hello,

This post was really helpfull but i need something extra for my case.

I want to display the total count of items of specific subcategories.


I now have the following category structure:

Parent Category A (0 Items)
- Child Category A (4 items)
- Child Category B (1 item)
- Child Category C (2 items)

Parent Category B (20 items)

Parent Category C (10 items)


So the goal is to display that the "Parent Category A" has 7 items

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

  • Dennis Miliopoulos
  • Dennis Miliopoulos's Avatar
  • Offline
  • Junior Member
More
9 years 5 months ago #125991 by Dennis Miliopoulos
Replied by Dennis Miliopoulos on topic Re: module which displays a total count of items
I found the solution to my previous post.

<?php
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(*) FROM #__k2_items i, #__k2_categories c WHERE i.catid = c.id AND i.published = 1 AND i.trash = 0 AND c.parent = xx");
$result = $db->loadResult();
?>

xx -> parent category id

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

More
9 years 3 months ago #136654 by IgorKysin
Replied by IgorKysin on topic Re: module which displays a total count of items
Hello, again!
This code counting piblished and dont trashed items. But if item published in future, code counting too. How exclude from counting pending items?
Thanks!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 months ago #136657 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: module which displays a total count of items
Hello,

Did you insert WHERE published = 1 in the query as well?

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