Advertisement:

Author Topic: Custom Profile Field - Sort Select Box/Radio Button Options  (Read 675 times)

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 655
  • Gender: Female
Custom Profile Field - Sort Select Box/Radio Button Options
« on: September 21, 2020, 10:34:27 AM »
Link to Mod

By default the options for 'Select Box' and 'Radio Button' in Custom Profile Fields cannot be sorted - they have to be reordered manually.  In situations where it is necessary to periodically add a new option like a calendar year and have the list displayed in descending order, or add a new model of an item and have the list displayed in ascending order, this can become quite time consuming.

This modification enables the ascending/descending sorting of the options for 'Select Box' and 'Radio Button' custom profile fields prior to them being saved.  There is also a 'No change' option (this is the default option) to preserve the order of the options if the Ascending or Descending sort options are not selected.

Also, and because care must be taken to not change the text when manually reordering options to ensure that user data is not lost, this mod provides a means to sort the options without any need to copy/paste/retype the text.



License
Copyright 2020 Kathy Leslie

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Life doesn't have to be perfect to be wonderful ...

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,633
  • Master of BBC Abuse
Re: Custom Profile Field - Sort Select Box/Radio Button Options
« Reply #1 on: September 21, 2020, 04:15:32 PM »
That's pretty spiffy. :)

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 655
  • Gender: Female
Re: Custom Profile Field - Sort Select Box/Radio Button Options
« Reply #2 on: September 21, 2020, 08:54:12 PM »
That's pretty spiffy. :)
Thanks for the compliment.

One of the forums I manage is for owners of a camper trailer that has been in continuous production for the last 26 years and over that time the company has manufactured 22 different models - and next year they'll still be in production and they will also be releasing some new models!

Up until now I've been editing the database directly to sort the year/model fields the way I wanted after adding new options but this mod makes it a whole lot easier!
Life doesn't have to be perfect to be wonderful ...

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 3,873
  • Gender: Male
  • Learning more every day!
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Custom Profile Field - Sort Select Box/Radio Button Options
« Reply #3 on: September 30, 2020, 09:02:39 PM »
I'm going to try it to see how it works, great job ;D and by the way I leave you the translation to Latin Spanish ;) (it is valid for Es also).

Code: (.spanish_latin) [Select]
$txt['custom_edit_sort_options'] = 'Ordenar las opciones de <em>\'Cuadro de selecci&oacute;n\'/\'Bot&oacute;n de opción\'</em> en el siguiente orden:';
$txt['custom_edit_sort_noChange'] = 'Sin cambios';
$txt['custom_edit_sort_ascending'] = 'Ascendente';
$txt['custom_edit_sort_descending'] = 'Descendente';

Code: (.spanish_latin-uf8) [Select]
$txt['custom_edit_sort_options'] = 'Ordenar las opciones de <em>\'Cuadro de selección\'/\'Botón de opción\'</em> en el siguiente orden:';
$txt['custom_edit_sort_noChange'] = 'Sin cambios';
$txt['custom_edit_sort_ascending'] = 'Ascendente';
$txt['custom_edit_sort_descending'] = 'Descendente';


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2020
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 655
  • Gender: Female
Re: Custom Profile Field - Sort Select Box/Radio Button Options
« Reply #4 on: September 30, 2020, 11:04:57 PM »
I'm going to try it to see how it works, great job ;D and by the way I leave you the translation to Latin Spanish ;) (it is valid for Es also).
Thanks - I've added the Spanish (Latin and ES) language text strings to the mod.
Life doesn't have to be perfect to be wonderful ...