I changed the code in linodef-editorbuttons-api.inc to meet my needs (field_name list sorted by node id descending to get the latest nodes first, nodes list sorted by title ascending):

// $result = db_query('SELECT n.%s as value, n.* FROM {%s} n', $fieldvalues['columns']['value']['column'], $fieldvalues['table']);
$result = db_query('SELECT n.%s as value, n.* FROM {%s} n order by n.nid desc', $fieldvalues['columns']['value']['column'], $fieldvalues['table']);

and

//$output[$i] = array('tag' => "[#". $ergebnis->nid .":". $fieldname .":". $ergebnis->delta ."]", 'desc' => $ergebnis->value ."(". $node->title .")");
$output[$i] = array('tag' => "[#". $ergebnis->nid .":". $fieldname .":". $ergebnis->delta ."]", 'desc' => $ergebnis->value ." (". $node->title .") [#" . $node->nid . "]");

Perhaps an additional parameter can be used to define the sort sequence in future versions?

Comments

pepe roni’s picture

Sorry, the second was an output modification ;)
Here is the change for node lists:

//$result = db_query('SELECT n.nid FROM {node} n WHERE n.type = "%s"', $contenttype);
$result = db_query('SELECT n.nid FROM {node} n WHERE n.type = "%s" order by n.title', $contenttype);
Roi Danton’s picture

Good idea. I think Buttons API should provide an admin form so the admin can set a default sort order for node and field buttons.

Though the disadvantage that you won't be able to set it for every single button is not as big as if the button code would be cluttered with tons of options (in rc2 there will be already three: "button type" will be new).

This will be included in rc3. I want to release rc2 with new tag syntax asap.

EDIT: So you'll have to change it in rc2 again. The file location has changed: linodef/modules/linodef_buttonsapi/includes/linodef_buttonsapi.inc

Roi Danton’s picture

Title: Sort the popup lists in BuEditor-Button » Sort options for the buttons itemlist
Status: Active » Fixed

Notwithstanding what I said before this feature is going to be a part of the RC2 release.
I've read your output modification, too and therefore added a title to the buttons. The title contains the tag the current item will insert.

Comitted to D6 branch. Please test the dev release on a test environment for bugs/flaws since with this dev update Linodef got tons of new features. RC2 will be released before Christmas unless major design bugs are found. If you find a bug relating this issue then reactivate it, please. Thx!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.