I have a custom content type with a node reference field. I have chosen the select list widget for my users to simply choose the title of the referenced node.

By default, Drupal orders these nodes alphabetically. I would like to have these nodes ordered by date created, descending.

I know I can change the default value by using a PHP snippet, but I'm not sure how to set up the array. Any ideas?

Comments

davexd’s picture

Same question here. Any updates?

(how do we re-order nodes in a nodereference field?)

WorldFallz’s picture

Node reference fields can also use views-- just create a view sorted the way you want and use that in the advanced settings for the node reference field.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

davexd’s picture

I'm working with the Slider module (http://drupal.org/project/slider), which takes its data straight from a nodereference field of one node. Any other ideas? :)

davexd’s picture

blueskiwi’s picture

yeah, but unless you want to make a new view for every node you're going to want to pass an argument to the view to tell it which nodes to select... that argument is probably the nid of the node you're using it from, ie a variable.

do tokens work in the argument field of the node-reference > view form?

because if you leave it blank the default argument setting code of the view doesn't happen, meaning you can't automatically fill in the argument with a variable:
http://drupal.org/node/349301

WorldFallz’s picture

do tokens work in the argument field of the node-reference > view form?

I have it working with tokens and it works great. If it's not part of the current release there's an issue in the issue queue with a patch.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz