My View has a " Global: Custom text"- Field that contains Integers (1,3, ..). The field is overwritten by a php-Template.

I want to add this field to "Sort criteria", so the view can be sorted - but how can I do this? the custom field does not show under "Sort criteria", how do i make it sortable?

1 Answer 1


You cannot sort by a global text field in views by default.

This is because global text field values are not populated until the view is being rendered, but the sorting of the view is done in the sql query, which is much before the global text field value exists.

One way to do it would be to add sorting ability with javascript. Because this would happen on the front end it could work for any fields. The views tablesorter module does this for drupal 6 table views but I have not yet found the time to make a drupal 7 version.

Another option is to make a custom views field handler that actually includes the data in the sql query or just making a custom sort handler.

For more information on creating handlers install the advanced help module and then go to the advanced help UI and look at the views help (advanced_help/views).

Your Answer

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

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