Skip to Content Skip to Menu

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

Possibility of example SQL script for CB Query

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
7 years 11 months ago #287834 by krileon
If you do not have a ton of usergroups I suggest simply using substitutions in a Custom HTML field as follows to avoid extra resource overhead of doing a query.

[cb:if usergroup includes "8"]
Super Users
[cb:elseif usergroup includes "7"]Administrator[/cb:elseif]
[cb:elseif usergroup includes "6"]Manager[/cb:elseif]
[cb:elseif usergroup includes "5"]Publisher[/cb:elseif]
[cb:elseif usergroup includes "4"]Editor[/cb:elseif]
[cb:elseif usergroup includes "3"]Author[/cb:elseif]
[cb:elseif usergroup includes "2"]Registered[/cb:elseif]
[/cb:if]

The above if specifically checking the group id, which you can find in Users > Groups from Joomla backend. Note support for ELSEIF substitution usage was just recently added. See the below blog for further details.

www.joomlapolis.com/blog/kyle/18708-substitution-power-up

I'll be updating the below substitution tutorial soon with the new functionality.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


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.

7 years 11 months ago #287851 by Paladin Brewer
Replied by Paladin Brewer on topic Possibility of example SQL script for CB Query
So I tried to copy/paste yours as is, and it doesn't seem to be working. The output on my profile (I am a super user, will display as:
Code:
Super Users [cb:elseif usergroup includes "7"]Administrator[/cb:elseif] [cb:elseif usergroup includes "6"]Manager[/cb:elseif] [cb:elseif usergroup includes "5"]Publisher[/cb:elseif] [cb:elseif usergroup includes "4"]Editor[/cb:elseif] [cb:elseif usergroup includes "3"]Author[/cb:elseif] [cb:elseif usergroup includes "2"]Registered[/cb:elseif]

So it seems to read the if statement, but the elseif statements are getting printed as text. For all the other users the field is just blank. I do have the newest 2.0.15 version of CB.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
7 years 11 months ago #287868 by krileon
You need the latest nightly build, which is 2.0.15+build.2016.11.14.14.09.35.fac6068a1. I've tested the exact substitution supplied to you as working fine.


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