Keyword

[SOLVED] retrieve the counter of k2 items, k2 users

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 9 months ago #129990 by George Nasis
hallo there!

i would like to know if there is any module to display the total number of k2 items, k2 authors and k2 comments. or if it is not possble can i take that number from the database to create a custom html module??

thank you very much

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #129991 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: retrieve the counter of k2 items, k2 users
Sadly no. You should create a custom module.

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 9 months ago #129992 by George Nasis
Replied by George Nasis on topic Re: retrieve the counter of k2 items, k2 users
thanx for the response Krikor!

yes i could not find so i made one. ;)

here is the code
Log in  or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #129993 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: retrieve the counter of k2 items, k2 users
Hello George,

I think you should use a module for this, not custom code, or at least use a high value for caching.

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 9 months ago #129994 by George Nasis
Replied by George Nasis on topic Re: retrieve the counter of k2 items, k2 users
hallo krikor,

as you said i don`t know any module to do this job. a use a module called "flexi custom code" with which you can write your code.

what do you mean by using a high value for caching?can you explain me what should i add in the code?

thank you

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #129995 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: retrieve the counter of k2 items, k2 users
No need to add anything in your code.
In your global configuration enable caching and use a value like 15 - 20 mins.

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
10 years 9 months ago #129996 by George Nasis
Replied by George Nasis on topic Re: retrieve the counter of k2 items, k2 users
oh that you mean.
yes of course

thank you a lot

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

More
10 years 9 months ago #129997 by laweffect
Replied by laweffect on topic Re: retrieve the counter of k2 items, k2 users
Don't forget that the K2 tools module allows you to add custom code, including PHP.

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

  • Giovanni Ciavarelli
  • Giovanni Ciavarelli's Avatar
  • Offline
  • New Member
More
10 years 3 weeks ago #143167 by Giovanni Ciavarelli
Replied by Giovanni Ciavarelli on topic [SOLVED] retrieve the counter of k2 items, k2 users
Hello!
Sorry .. I am not able to do this! I installed flexy and Copy/Pasted the code but on the frontend it's showing the code ... not the result! :-(

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 weeks ago #143179 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] retrieve the counter of k2 items, k2 users
Try using the K2 Tools module and enable the PHP related setting.

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

  • Giovanni Ciavarelli
  • Giovanni Ciavarelli's Avatar
  • Offline
  • New Member
More
10 years 2 weeks ago #143184 by Giovanni Ciavarelli
Replied by Giovanni Ciavarelli on topic [SOLVED] retrieve the counter of k2 items, k2 users
Hi Krikor,
Unfortunately I did It but It does not work for me. Still Showing Code despite the "result"


Here I prepare custom module
i.imgur.com/PRdq1vt.png

And this is the result, on the right
i.imgur.com/Mq7ZgI5.png

Sorry, I am a noob! :)

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 1 week ago #143580 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] retrieve the counter of k2 items, k2 users
You forgot the <?php ?> brackets for the first part of the code.

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

  • Franz Wohlkönig
  • Franz Wohlkönig's Avatar
  • Offline
  • Platinum Member
More
10 years 1 week ago #143585 by Franz Wohlkönig
Replied by Franz Wohlkönig on topic [SOLVED] retrieve the counter of k2 items, k2 users
for non-Devs like me: this works

<?php
$db = JFactory::getDBO();
$query = "SELECT COUNT(*) FROM #__users";
$db->setQuery($query);
$result = $db->loadresult();?>
<?php echo "$result" ?>

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

  • Giovanni Ciavarelli
  • Giovanni Ciavarelli's Avatar
  • Offline
  • New Member
More
10 years 1 week ago #143592 by Giovanni Ciavarelli
Replied by Giovanni Ciavarelli on topic [SOLVED] retrieve the counter of k2 items, k2 users
Thank you all for helping me!

I changed this line
FROM #__k2_items";

to retrive total number of Items!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 1 week ago #143594 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] retrieve the counter of k2 items, k2 users
Nice to hear that you got it working Giovanni.

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