0

I have an entity reference field which references and displays multiple nodes on a Drupal 7 install.
I am trying to get them to display in date order (the date is a field on the referenced nodes). The problem I have is that if a referenced node date is changed, or a new one created, the display order doesn't change.

I use a entity reference view to order the nodes on their date fields, which works when you manually edit the master node and then save it. This then updates the order. However this not a very practical solution.

I have tried creating a module which when referenced nodes are modified or created, it programatically loads and saves the master node using node_load and node_save.

However this doesn't trigger the referenced nodes to update their display order.

Does anyone know anything else I can try?

0
  1. Go to Structure > Content types and select your content type.
  2. Click the "Manage Fields" tab.
  3. Click edit next to your entity reference field.

There should be a "FIELD SETTINGS" area with an "ENTITY SELECTION" box. At the bottom of the "ENTITY SELECTION" box, there's a "Sort by" drop-down menu that should let you select "A field attached to this entity." That should give you access to the date field that you want to use as your sort value.

  • Thanks for the suggestion, I have tried that. It sorts the content perfectly in the content edit area. But doesn't change the order when you render the field. – inertiahz Feb 18 '18 at 13:35
  • It looks like this might help: Display order of entity reference fields – sjhuskey Feb 19 '18 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.