[SOLVED] get component param in Query Drop Down field?

5 years 4 days ago - 5 years 2 days ago #311954 by cpaschen
I have a Query Drop Down (Multi-select) field with the following query:
SELECT id, DATE_FORMAT(date, '%M %e') as formatted_date
FROM oq7ve_sportscoop_sport_date
WHERE sport = 1 AND year = 2019

It is working fine; however, I need to change it so that it gets the year value in the WHERE clause (i.e. 2019) from the component parameters of a custom component.

If I could run PHP here I would use something like this:
$programYear = JComponentHelper::getParams('com_sportscoop')->get('sys_program_year');

And then just change the where clause to:
WHERE sport = 1 AND year = $programYear

Is there any way to do this within CB - to pull that component param in to use it as part of the WHERE clause in this query?

Please Log in to join the conversation.

5 years 3 days ago #311959 by krileon
Replied by krileon on topic get component param in Query Drop Down field?
Use a CB Code Field to execute your code then substitute it into your query. CB Query Field can not run PHP. You could also use a Code Select and have it done entirely in PHP.


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 to join the conversation.

5 years 3 days ago #311970 by cpaschen
Replied by cpaschen on topic get component param in Query Drop Down field?
Thanks!
The code field and then with the substitution worked.

I tried initially to use the Code Select field, but had problems trying to get the data returned in the array format that it needed (it just kept displaying only one record).
If I need to use that in the future (code select) I'll have to get back to you for more help.

But for now, this is working GREAT!
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.202 seconds

Facebook Twitter LinkedIn