views_handler_sort_menu_hierarchy.inc

  1. 3.x handlers/views_handler_sort_menu_hierarchy.inc
  2. 2.x handlers/views_handler_sort_menu_hierarchy.inc

File

handlers/views_handler_sort_menu_hierarchy.inc
View source
  1. <?php
  2. /**
  3. * Sort in menu hierarchy order.
  4. *
  5. * Given a field name of 'p' this produces an ORDER BY on p1, p2, ..., p9.
  6. * This is only really useful for the {menu_links} table.
  7. *
  8. * @ingroup views_sort_handlers
  9. */
  10. class views_handler_sort_menu_hierarchy extends views_handler_sort {
  11. function query() {
  12. $this->ensure_my_table();
  13. $max_depth = isset($this->definition['max depth']) ? $this->definition['max depth'] : MENU_MAX_DEPTH;
  14. for ($i = 1; $i <= $max_depth; ++$i) {
  15. $this->query->add_orderby($this->table_alias, $this->field . $i, $this->options['order']);
  16. }
  17. }
  18. }