Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Query field Kunena new messages

  • tiekubd
  • tiekubd
  • OFFLINE
  • Posts: 68
  • Thanks: 1
  • Karma: 0
8 years 8 months ago #278141 by tiekubd
Query field Kunena new messages was created by tiekubd
I was able to use a CB query field to get the count of unread uddeIM messages:

SELECT COUNT(*) FROM `#__uddeim` WHERE `toid`='[user_id]' AND `toread`='0';

Can you give me the CB query to get the count of new messages in a category in Kunena for a given user?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago #278178 by krileon
Replied by krileon on topic Query field Kunena new messages

Can you give me the CB query to get the count of new messages in a category in Kunena for a given user?

Please understand I am not here to write custom code or queries for you on request. I can provide you with simple examples at best, which you already have above. You'll need to review the Kunena database table to write a query based off that.

Your post also would make better sense in the Kunena forums as we are not the developers of Kunena and did not create its database structure. Once you've the query you would replace the user id usage in it with '[user_id]' to substitute in the user id for CB Query Field usage.

With that said the below would probably work. Consult with Kunena for further help on writing Kunena queries. Note this may also be outside their scope of support as writing custom code for you is not support, sorry.

Code:
SELECT COUNT(*) FROM `#__kunena_messages` WHERE `catid` = CATEGORY_ID_HERE AND `userid` = '[user_id]'


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: nant

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

  • tiekubd
  • tiekubd
  • OFFLINE
  • Posts: 68
  • Thanks: 1
  • Karma: 0
8 years 8 months ago #278197 by tiekubd
Replied by tiekubd on topic Query field Kunena new messages
I poured through the kunena files and found the variable that holds the new messages count value I want. Is there a way to display php variables in the query field?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago #278224 by krileon
Replied by krileon on topic Query field Kunena new messages
No, for that you need to use a CB Code Field which can display the results of PHP as a field value.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

  • tiekubd
  • tiekubd
  • OFFLINE
  • Posts: 68
  • Thanks: 1
  • Karma: 0
8 years 8 months ago #278428 by tiekubd
Replied by tiekubd on topic Query field Kunena new messages
I can't get the code field to work.
If I put this in the code box to test:

return 'Age';

should I not see the text "Age"?
Attachments:

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago #278437 by krileon
Replied by krileon on topic Query field Kunena new messages
Yes, you should see the word Age displayed. Ensure you are not including the php open and close tags as your code is parsed as an anonymous PHP function. Enable debug mode and maximum error reporting during testing to ensure no errors are occurring. Please ensure you're correctly using the Code fieldtype and not code validation or a code select type.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

Moderators: beatnantkrileon
Powered by Kunena Forum