Answers.Body: <p>Every option value choice has a description field that often isn't used. Put the white/non-white value in that field on each choice, and then display the description field in the searchkit instead.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-11T17:47:17.857Z
Answers.Text: That's a good suggestion although SK doesn't have a ui for specifying which attribute of an option list you want to display. Arguably, it should.
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-11T18:12:33.667Z
Answers.Text: I was thinking in the rewrite for the field, you just change "label" to "description". Or you could, except when I try it that always seems to come out blank. Not sure if that's a bug.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-11T22:37:51.877Z
Answers.Text: Maybe it was a cache problem. It seems to be working now. So in the rewrite in the display, you just put e.g. `[constituent_information.Marital_Status:description]` instead of the default `[constituent_information.Marital_Status:label]`.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-11T23:43:12.727Z
Answers.Text: You're right! You can do it with rewrite... but how about this for a nicer UX - https://github.com/civicrm/civicrm-core/pull/31100
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-12T01:42:25.710Z
Answers.Text: Thinking about this more the right field for this specific use-case is `grouping`, but I guess because it's "internal" and if you're setting it you don't really want people changing it, so that's probably why it doesn't show up anywhere.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-12T12:54:45.617Z
Answers.Text: My only comment is that when I use grouping, it currently counts the values *before* it does the rewrite, so it has more rows than I'd like. I'd really liek the option to count after the rewrite if that is possible...
Answers.UserDisplayName: Rose Lanigan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-12T14:55:22.887Z
Answers.Text: Just to clarify by `grouping` I meant the field civicrm_option_value.grouping, not sql "group by". But it sounds like you're saying sql "group by" in searchkit won't count rewrites properly. In that case what you'd need is a sql "case" operator in the select (https://dev.mysql.com/doc/refman/8.4/en/flow-control-functions.html#operator_case). But I don't think search kit has that transformation available.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-12T14:57:50.183Z
Answers.Text: It's a bit of overkill but what you could do is create an api4 entity in code that represents your mapping from ethnicity to white/non-white, then join on that in the search.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-12T15:03:43.427Z
Answers.Text: Or, have a view-only custom field whose value you compute in hook_civicrm_post, then use that in the search.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-11T15:27:08.030Z
Answers.LastActivityDate: 2024-09-11T15:27:08.030Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>I recommend using a SearchSegment. This allows you to group ethnicities into categories, then you can group by and report on that category.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-09-13T14:53:03.127Z
Answers.LastActivityDate: 2024-09-13T14:53:03.127Z
Answers.UserDisplayName: Coleman
Body: <p>I have a field for Ethnicity with approx 20+ options to choose from, but the local authority only use White/Non-white classifications for somethings (I don't know why...)</p>
  <p>I think it's possible to use the rewrite option in Search Kit with smarty but I can't find any straight forward documentation to get my head around smarty. Can anyone suggest some good documentation? The official documentation seems more related to the integration of it rather than writing it. There are a couple of examples on stackexchange but nothing specific enough that helps me write something for this scenario.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-09-11T15:07:38.210Z
Comments.Text: Unfortunately, the documentation on Stack Exchange is the only CiviCRM-specific Smarty docs for SearchKit.  You might get more help by explaining in more detail what your specific need is.  There's also the official Smarty documentation for additional help.
Comments.UserDisplayName: Jon G - Megaphone Tech
Tags: <searchkit><smarty>
Title: Using Smarty in Search Kit
ThreadText: # Using Smarty in Search Kit
  
  (Asked by: username_0 on 2024-09-11)
  
  I have a field for Ethnicity with approx 20+ options to choose from, but the local authority only use White/Non-white classifications for somethings (I don't know why...)
  
  I think it's possible to use the rewrite option in Search Kit with smarty but I can't find any straight forward documentation to get my head around smarty. Can anyone suggest some good documentation? The official documentation seems more related to the integration of it rather than writing it. There are a couple of examples on stackexchange but nothing specific enough that helps me write something for this scenario.
  
  **Tags:** searchkit, smarty
  
  > **Comments:**
  > **username_1**: Unfortunately, the documentation on Stack Exchange is the only CiviCRM-specific Smarty docs for SearchKit.  You might get more help by explaining in more detail what your specific need is.  There's also the official Smarty documentation for additional help.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2024-09-11. Score: 2
  
  Every option value choice has a description field that often isn't used. Put the white/non-white value in that field on each choice, and then display the description field in the searchkit instead.
  
  > **Comments:**
  > **username_3**: That's a good suggestion although SK doesn't have a ui for specifying which attribute of an option list you want to display. Arguably, it should.  
  > **username_2**: I was thinking in the rewrite for the field, you just change "label" to "description". Or you could, except when I try it that always seems to come out blank. Not sure if that's a bug.  
  > **username_2**: Maybe it was a cache problem. It seems to be working now. So in the rewrite in the display, you just put e.g. `[constituent_information.Marital_Status:description]` instead of the default `[constituent_information.Marital_Status:label]`.  
  > **username_3**: You're right! You can do it with rewrite... but how about this for a nicer UX - https://github.com/civicrm/civicrm-core/pull/31100  
  > **username_2**: Thinking about this more the right field for this specific use-case is `grouping`, but I guess because it's "internal" and if you're setting it you don't really want people changing it, so that's probably why it doesn't show up anywhere.  
  > **username_0**: My only comment is that when I use grouping, it currently counts the values *before* it does the rewrite, so it has more rows than I'd like. I'd really liek the option to count after the rewrite if that is possible...  
  > **username_2**: Just to clarify by `grouping` I meant the field civicrm_option_value.grouping, not sql "group by". But it sounds like you're saying sql "group by" in searchkit won't count rewrites properly. In that case what you'd need is a sql "case" operator in the select (https://dev.mysql.com/doc/refman/8.4/en/flow-control-functions.html#operator_case). But I don't think search kit has that transformation available.  
  > **username_2**: It's a bit of overkill but what you could do is create an api4 entity in code that represents your mapping from ethnicity to white/non-white, then join on that in the search.  
  > **username_2**: Or, have a view-only custom field whose value you compute in hook_civicrm_post, then use that in the search.  
  
  ---
  
  ### Answer by username_3 on 2024-09-13. Score: 1
  
  I recommend using a SearchSegment. This allows you to group ethnicities into categories, then you can group by and report on that category.
  
  
  ---
  
  