I have a custom content type which is rendered by a custom tpl php. I would like to have the ability to control the order in which the fields are displayed for each contents.

I can use the order of the fields defined in the content type, but that will affect all the contents for that content type. Can I have some field in which I can specify the order of the content types that is being displayed? So that based on the field containing the order, I will render the fields in configured order.

Or else what would be the best way to do that, so that I can get control over the order of each content?

2 Answers 2


It's not clear how you define the order of the field, but if you put extra information in the node and want to use this to change the order of the fields before output, you can use the weight property to change the order in an alter hook:

hook_node_view_alter(&$build) {
if ( $build['field_sort_order']['0']['#text'] == 'sort it this way' ) {
   $build['field1']['#weight'] = -10;
   $build['field2']['#weight'] = 10;
  • Similar to this. But I need weight for each field to be configurable for each content. Not through code. Oct 19, 2015 at 6:32

Field display weights (per node) is the solution. This allows me to configure the order of the fields for each nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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