This is a my code. I show menu in page and children pages. The question is, how to show this menu in children's all children pages?
/**
* Implements hook_preprocess_page().
*/
function agnian_material_admin_preprocess_page(&$variables) {
// @todo: add an if statement to add below data only for "page__admin__content" page.
$variables['node_types'] = node_type_get_names();
/** * Render "admin/structure" page's menu in it's all subpages. */
// get current page path
$path = \Drupal::request()->getPathInfo();
if(strpos($path, '/admin/structure') !== false) {
$tree = \Drupal::menuTree();
$params = $tree->getCurrentRouteMenuTreeParameters('admin');
$admin_menu = $tree->load('admin', $params);
$admin_structure_menu = array_key_exists('system.admin_structure', $admin_menu['system.admin']->subtree) ? $admin_menu['system.admin']->subtree['system.admin_structure'] : null;
if($admin_structure_menu) {
$subtree = $tree->build($admin_structure_menu->subtree);
/* this part is only for syncing menu items positions between "admin/structure" page and it's child pages */
$old_items = $subtree['#items'];
$tmp = $subtree['#items'] = array();
foreach($old_items as $key => $value) $tmp[$key] = $value['title'];
asort($tmp);
foreach($tmp as $key => $value) $subtree['#items'][$key] = $old_items[$key];
/* end of sync */
$variables['admin_menu'] = $subtree;
}
}
/** End Of Render "admin/structure" page's menu in it's all subpages. */ }
s child x1 , and not shown in x1
s child x2 ( x > x1> x2 ). MY problem is to show is menu in x2 and x3 pages. – Evi