Solved: 1 Year, 6 Months, 2 Weeks ago order alphabetically theme selector?
#1
Solved: 1 Year, 6 Months, 2 Weeks ago
This user has been denied support. This user has been denied support.
Hey,

Is it possible to order alphabetically theme selector theme names?

Regards.
Reply
#2
Solved: 1 Year, 6 Months, 2 Weeks ago
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.
Reply
#3
Solved: 1 Year, 6 Months, 2 Weeks ago
This user has been denied support. 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:
[Image: 34d500d7b4.png]

Edit: Worked. When I use below code.

$query = $db->simple_select('themes', 'tid, name, pid, allowedgroups', "pid!='0'", array("order_by" => "name"));
Reply
#4
Solved: 1 Year, 6 Months, 2 Weeks ago
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.
Reply
#5
Solved: 1 Year, 6 Months, 2 Weeks ago
This user has been denied support. 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"));
Reply
#6
Solved: 1 Year, 6 Months, 2 Weeks ago
(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...
Reply
#7
Solved: 1 Year, 6 Months, 2 Weeks ago
This user has been denied support. 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"));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)