- Posts: 6
COMMUNITY FORUM
[SOLVED] module which displays a total count of items
- Machroel
- Topic Author
- Offline
- New Member
Less
More
10 years 2 weeks ago #125974
by Machroel
[SOLVED] module which displays a total count of items was created by Machroel
Hi K2 users,
I am new in using K2 and after a long search I am wondering: Is there a module which displays a total count of all items or categories? Maybe I didn't look right, but I just can't seem to find it.
Is there anyone who could help me finding an answer? Thanks in advance!
I am new in using K2 and after a long search I am wondering: Is there a module which displays a total count of all items or categories? Maybe I didn't look right, but I just can't seem to find it.
Is there anyone who could help me finding an answer? Thanks in advance!
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
10 years 2 weeks ago #125975
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: module which displays a total count of items
Hi. There is such a module in administration. What do you want to achieve exactly?
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Machroel
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
10 years 2 weeks ago #125976
by Machroel
Replied by Machroel on topic Re: module which displays a total count of items
thanks for answering...
I just want my visitors to show (in a module) how many items/articles I have in total.
My items are guitar tabs for musicians and therefor it is nice to see how many tabs and artists or bands are published on my website.
So there is a K2 module in administrator which will do this? Can you tell me which one?
I just want my visitors to show (in a module) how many items/articles I have in total.
My items are guitar tabs for musicians and therefor it is nice to see how many tabs and artists or bands are published on my website.
So there is a K2 module in administrator which will do this? Can you tell me which one?
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
10 years 2 weeks ago #125977
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: module which displays a total count of items
This module is used in administration only and can't be used for guests. You can however try:
Note that this code does not take into consideration the access level of the items and the start publishing and finish publishing dates.
<?php
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(*) FROM #__k2_items WHERE published = 1 AND trash = 0");
$result = $db->loadResult();
?>
<span>Total : <?php echo $result; ?></span>
Note that this code does not take into consideration the access level of the items and the start publishing and finish publishing dates.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Machroel
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
10 years 2 weeks ago #125978
by Machroel
Replied by Machroel on topic Re: module which displays a total count of items
Thanks very much for your reply! I wil try your solution and let you know the results!
Please Log in or Create an account to join the conversation.
- Machroel
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
10 years 2 weeks ago #125979
by Machroel
Replied by Machroel on topic Re: module which displays a total count of items
..maybe a stupid question to ask...but where-in which file- should I put these lines?
<?php
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(*) FROM #__k2_items WHERE published = 1 AND trash = 0");
$result = $db->loadResult();
?>
I placed your last line: <span>Total : <?php echo $result; ?></span> in a HTML Module
Sorry for my ignorance...
<?php
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(*) FROM #__k2_items WHERE published = 1 AND trash = 0");
$result = $db->loadResult();
?>
I placed your last line: <span>Total : <?php echo $result; ?></span> in a HTML Module
Sorry for my ignorance...
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
10 years 2 weeks ago #125980
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: module which displays a total count of items
This depends where you want to put this. Joomla! custom HTML module does not allow PHP execution so you might want to use the K2 Tools custom code module.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Machroel
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
10 years 1 week ago #125981
by Machroel
Replied by Machroel on topic Re: module which displays a total count of items
Thank you.. :) The K2 custom field -module tools- does the work indeed! It is still though not presize what I want [it now shows Month-Year (total)...and I just want total: (99)] ...but it gives me enough direction to work with.
Thanks again for your expertise!
Thanks again for your expertise!
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
10 years 1 week ago #125982
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: module which displays a total count of items
Probably you have misused the module. I suggested to set K2 tools usage to custom code and then use the code i provided. Probably are using the K2 tools module as archive.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Machroel
- Topic Author
- Offline
- New Member
Less
More
- Posts: 6
10 years 5 days ago #125983
by Machroel
Replied by Machroel on topic Re: module which displays a total count of items
That's it!!! Thank you, thank you!
I misused the module as you said. I choose archive where I needed to choose ' custom' .
' Problem' solved :)
I misused the module as you said. I choose archive where I needed to choose ' custom' .
' Problem' solved :)
Please Log in or Create an account to join the conversation.