Skip to Content Skip to Menu

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

User List - Advanced Sorting

  • sirweb
  • sirweb
  • ONLINE
  • Posts: 226
  • Thanks: 25
  • Karma: 2
8 years 11 months ago #272981 by sirweb
User List - Advanced Sorting was created by sirweb
I am trying to sort a Uer List with an advanced sorting criteria, where I want to sort on the ordering on a selectfield with ID=107.
In phpMyAdmin, I run the following command, which gives the result I want.
Code:
SELECT fieldtitle FROM #_comprofiler_field_values WHERE fieldid = '107' ORDER BY ordering ASC

My question is how to transform this query to a usable CB sorting query?
As I understand, ue. prefix is not usable for CB table #_comprofiler_field_values ???

Thanks for pointing me in the right direction.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
8 years 11 months ago #273013 by krileon
Replied by krileon on topic User List - Advanced Sorting
If your field value and title are the same you can just use the Basic sorting to sort by your field. If you still want to use an Advanced sorting query then it depends on if your field is single or multi select. Please note your #_ prefix should be #__. You also should use ` around table and column names.


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: sirweb

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

  • sirweb
  • sirweb
  • ONLINE
  • Posts: 226
  • Thanks: 25
  • Karma: 2
8 years 11 months ago #273063 by sirweb
Replied by sirweb on topic User List - Advanced Sorting
I have a multi select field where I want to sort on the order the field options as they appear in the option list. It is multiselect because one person can have more than one occupation.
For example, field cb_occupation has the following options:

Fieldtitle Ordering
headmaster 1
teacher 2
assistant 3
student 4
and I want to sort the user list on Occupation, in that hierarchical order.
If multiole options for someone, like "teacher|*|assistant", teacher is higher and used for sorting. Obviously, I cannot use simple ASC or DESC ordering of the list.

Hope you can unserstand what I am trying to explain.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
8 years 11 months ago - 8 years 11 months ago #273121 by krileon
Replied by krileon on topic User List - Advanced Sorting
Ah, I understand. The issue is it's a multiselect. If you already have the options sorted from greatest to lowest you can probably grab the first value of the field then sort based off that options ordering. So the Advanced sorting usage below may work.

Code:
SELECT fv.`ordering` FROM `#__comprofiler_field_values` AS fv WHERE fv.`fieldvalueid` = SUBSTRING_INDEX( ue.`FIELD_NAME`, '|*|', 1 )


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.
Last edit: 8 years 11 months ago by krileon.
The following user(s) said Thank You: sirweb

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

  • sirweb
  • sirweb
  • ONLINE
  • Posts: 226
  • Thanks: 25
  • Karma: 2
8 years 11 months ago #273171 by sirweb
Replied by sirweb on topic User List - Advanced Sorting
Thanks for your help!

One step closer, but unfortunately, it generates error 1064.
Thinking: Do we need to address the issue with multiselect fields, that we have:
- e option is selected, or
- o or more options are selected
using an IF statement?

I guess I need to do more of my own homework too. :)
at this point, I am a bit confused over the syntax. Like which prefixes are allowed, fv. u. ue.... Maybe I have not found all documentation yet.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
8 years 11 months ago #273277 by krileon
Replied by krileon on topic User List - Advanced Sorting
Please provide the full error message.

at this point, I am a bit confused over the syntax. Like which prefixes are allowed, fv. u. ue.... Maybe I have not found all documentation yet.

We have no documentation for this as it's just standard SQL. See the below for MYSQL documentation.

dev.mysql.com/doc/refman/5.6/en/


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