Posts: 209
Threads: 57
Joined: Dec 2022
Reputation:
1
2023-07-08, 10:51 PM
This user has been denied support.
Hey,
Is it possible to order alphabetically theme selector theme names?
Regards.
Posts: 869
Threads: 88
Joined: Jul 2016
Reputation:
116
2023-07-09, 01:14 AM
(This post was last modified: 2023-07-09, 01:17 AM by HLFadmin.)
It appears the theme selector is populated from a query at line 5588 in inc/functions.php
5588 $query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");
simple_select function builds the query and permits query options. This code is from inc/db_mysqli.php
760 /**
761 * Performs a simple select query.
762 *
763 * @param string $table The table name to be queried.
764 * @param string $fields Comma delimetered list of fields to be selected.
765 * @param string $conditions SQL formatted list of conditions to be matched.
766 * @param array $options List of options: group by, order by, order direction, limit, limit start.
767 * @return mysqli_result The query data.
768 */
769 function simple_select($table, $fields="*", $conditions="", $options=array())
Looking at other simple_select() function calls, you could add an order_by option to the original query.
This is a core edit and is untested on my forum, but *should* work. Be prepared to revert the change.
Change line 5588 in inc/functions.php
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");
to
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name", "order_dir" => "desc"));
Obviously, core edits need to be repeated if a version update changes the inc/functions.php file.
Posts: 209
Threads: 57
Joined: Dec 2022
Reputation:
1
2023-07-09, 03:59 PM
(This post was last modified: 2023-07-09, 04:04 PM by jkcool. Edited 2 times in total.)
This user has been denied support.
(2023-07-09, 01:14 AM)HLFadmin Wrote: It appears the theme selector is populated from a query at line 5588 in inc/functions.php
5588 $query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'");
simple_select function builds the query and permits query options. This code is from inc/db_mysqli.php
760 /**
761 * Performs a simple select query.
762 *
763 * @param string $table The table name to be queried.
764 * @param string $fields Comma delimetered list of fields to be selected.
765 * @param string $conditions SQL formatted list of conditions to be matched.
766 * @param array $options List of options: group by, order by, order direction, limit, limit start.
767 * @return mysqli_result The query data.
768 */
769 function simple_select($table, $fields="*", $conditions="", $options=array())
Looking at other simple_select() function calls, you could add an order_by option to the original query.
This is a core edit and is untested on my forum, but *should* work. Be prepared to revert the change.
Change line 5588 in inc/functions.php
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'"); to
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name", "order_dir" => "desc"));
Obviously, core edits need to be repeated if a version update changes the inc/functions.php file.
Worked. But I want to show like this: Duende v3, Roundo Dark, Roundo Light, Simplicity Dark, Simplicity Light
And its showing like this:
Edit: Worked. When I use below code.
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name"));
Posts: 869
Threads: 88
Joined: Jul 2016
Reputation:
116
2023-07-09, 04:46 PM
Sorry. Desc is Z-A, Asc is A-Z and defualt.
I was one cup of coffee short when I posted that.
Glad you verified it's working.
Posts: 209
Threads: 57
Joined: Dec 2022
Reputation:
1
2023-07-09, 06:41 PM
This user has been denied support.
(2023-07-09, 04:46 PM)HLFadmin Wrote: Sorry. Desc is Z-A, Asc is A-Z and defualt.
I was one cup of coffee short when I posted that.
Glad you verified it's working.
I have used asc but it didnt worked.
So, I have used this:
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name"));
Posts: 417
Threads: 57
Joined: Mar 2019
Reputation:
27
2023-07-10, 12:57 PM
(2023-07-09, 06:41 PM)jkcool Wrote: (2023-07-09, 04:46 PM)HLFadmin Wrote: Sorry. Desc is Z-A, Asc is A-Z and defualt.
I was one cup of coffee short when I posted that.
Glad you verified it's working.
I have used asc but it didnt worked.
So, I have used this:
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name"));
That's not using ascending.
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name", "order_dir" => "asc"));
^ You have to replace the desc with asc...
Posts: 209
Threads: 57
Joined: Dec 2022
Reputation:
1
2023-07-10, 08:13 PM
This user has been denied support.
(2023-07-10, 12:57 PM)Taylor M Wrote: (2023-07-09, 06:41 PM)jkcool Wrote: (2023-07-09, 04:46 PM)HLFadmin Wrote: Sorry. Desc is Z-A, Asc is A-Z and defualt.
I was one cup of coffee short when I posted that.
Glad you verified it's working.
I have used asc but it didnt worked.
So, I have used this:
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name"));
That's not using ascending.
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name", "order_dir" => "asc")); ^ You have to replace the desc with asc...
Its not showing in ascending order so I am using below code. But this code is only showing ascending on 1 theme only.
$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name"));
|