You are here

function tb_megamenu_sync_order_menus in The Better Mega Menu 7

1 call to tb_megamenu_sync_order_menus()
tb_megamenu_update_megamenus in ./tb_megamenu.functions.inc
Update items in tb_megamenus table.

File

./tb_megamenu.functions.inc, line 231

Code

function tb_megamenu_sync_order_menus(&$menu_config) {
  foreach ($menu_config as $mlid => $config) {
    foreach ($config['rows_content'] as $rows_id => $row) {
      $item_sorted = array();

      // Get weight from items.
      foreach ($row as $col) {
        foreach ($col['col_content'] as $menu_item) {
          if ($menu_item['type'] == 'menu_item') {
            $item_sorted[$menu_item['weight']] = $menu_item;
          }
        }
      }
      ksort($item_sorted);

      // Sort menu by weight.
      foreach ($row as $rid => $col) {
        foreach ($col['col_content'] as $menu_item_id => $menu_item) {
          if ($menu_item['type'] == 'menu_item') {
            $menu_config[$mlid]['rows_content'][$rows_id][$rid]['col_content'][$menu_item_id] = array_shift($item_sorted);
          }
        }
      }
    }
  }
}