Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: GL700Wing on September 21, 2020, 10:34:27 AM

Title: Custom Profile Field - Sort Select Box/Radio Button Options
Post by: GL700Wing on September 21, 2020, 10:34:27 AM
Link to the mod (https://custom.simplemachines.org/index.php?mod=4268)

Custom Profile Field Sort Options for Select Box/Radio Button - v1.2

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.


Release History:
1.0 - 20-Aug-20
o Initial Release with support only for SMF 2.0.17

1.0 Update - 12-Oct-20
o Added installer support for SMF 2.0.18 (no code change for mod)

1.1 - 25-Jul-21
o Added support for SMF 2.1 RC4

1.2 - 23-Apr-22
o Added installer support for SMF 2.1
o Removed installer support for SMF 2.1 RC4
o Fixed minor bug for SMF 2.1




License
Copyright 2020-2023 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.
Title: Re: Custom Profile Field - Sort Select Box/Radio Button Options
Post by: Antechinus on September 21, 2020, 04:15:32 PM
That's pretty spiffy. :)
Title: Re: Custom Profile Field - Sort Select Box/Radio Button Options
Post by: GL700Wing on September 21, 2020, 08:54:12 PM
Quote from: Antechinus on September 21, 2020, 04:15:32 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!
Title: Re: Custom Profile Field - Sort Select Box/Radio Button Options
Post by: -Rock Lee- 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!
Title: Re: Custom Profile Field - Sort Select Box/Radio Button Options
Post by: GL700Wing on September 30, 2020, 11:04:57 PM
Quote from: Rock Lee 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).
Thanks - I've added the Spanish (Latin and ES) language text strings to the mod.
Title: Re: Custom Profile Field - Sort Select Box/Radio Button Options
Post by: GL700Wing on July 26, 2021, 02:23:17 AM
Uploaded 1.1 - 25-Jul-21
o Added support from SMF 2.1 RC4
Title: Re: Custom Profile Field - Sort Select Box/Radio Button Options
Post by: GL700Wing on April 22, 2022, 12:02:58 AM
Version 1.2 - 22-Apr-22
o Added installer support for SMF 2.1
o Removed installer support for SMF 2.1 RC4
o Fixed minor bug for SMF 2.1