From e55ebcca2a10e7ba4d189099b4aa46ff6e5f864f Mon Sep 17 00:00:00 2001 From: Matthew Grasmick Date: Wed, 15 Aug 2018 18:04:39 +0000 Subject: [PATCH] Issue #2992858: List two levels of guide content in documentation guides --- .../plugins/content_types/section_contents.inc | 58 ++++++++++++++++++---- .../drupalorg_content_types.strongarm.inc | 5 ++ 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/drupalorg/plugins/content_types/section_contents.inc b/drupalorg/plugins/content_types/section_contents.inc index fb55fca..ba519a1 100644 --- a/drupalorg/plugins/content_types/section_contents.inc +++ b/drupalorg/plugins/content_types/section_contents.inc @@ -15,25 +15,61 @@ $plugin = [ function drupalorg_section_contents($subtype, $conf, $args, $context = NULL) { $block = new stdClass(); $block->content = ''; - if (isset($context->keyword) && $context->keyword === 'node' && isset($context->data) && (list($og_menu) = og_menu_get_group_menus(['node' => [$context->data->nid]]))) { - if ($menu = menu_tree($og_menu['menu_name'])) { - // Find nodes in the menu. - $nids = []; - foreach (element_children($menu) as $key) { - if ($menu[$key]['#original_link']['router_path'] === 'node/%') { - $nids[] = preg_replace('#^node/#', '', $menu[$key]['#original_link']['link_path']); - } - } - + if (isset($context->keyword) && $context->keyword === 'node' && isset($context->data)) { + // Find nodes in the menu. + if ($nids = drupalorg_get_og_menu_nids($context->data->nid)) { // Render those nodes. if (!empty($nids)) { foreach (node_load_multiple($nids) as $node) { $wrapper = entity_metadata_wrapper('node', $node); $uri = entity_uri('node', $node); - $block->content .= '

' . l($node->title, $uri['path'], $uri['options']) . '

' . check_plain($wrapper->field_summary->value()) . '

'; + $block->content .= '

' . l($node->title, $uri['path'], + $uri['options']) . '

' . check_plain($wrapper->field_summary->value()) . '

'; + $content_nids = drupalorg_get_og_menu_nids($node->nid); + if (!empty($content_nids)) { + $block->content .= ''; + } + + $block->content .= '
'; } } } } + return $block; } + +/** + * Gets the nids of nodes in a given group's menu. + + * @param int $nid + * The node id of the group. + * + * @return array + * An array of node ids of the group menu items. + */ +function drupalorg_get_og_menu_nids($nid) { + $menu_item_nids = []; + $groups = ['node' => [$nid]]; + $menus = og_menu_get_group_menus($groups); + if ($menus) { + $og_menu = $menus[0]; + $menu_item_nids = []; + if ($menu = menu_tree($og_menu['menu_name'])) { + foreach (element_children($menu) as $key) { + if ($menu[$key]['#original_link']['router_path'] === 'node/%') { + $menu_item_nids[] = preg_replace('#^node/#', '', + $menu[$key]['#original_link']['link_path']); + } + } + } + } + + return $menu_item_nids; +} diff --git a/features/drupalorg_content_types/drupalorg_content_types.strongarm.inc b/features/drupalorg_content_types/drupalorg_content_types.strongarm.inc index f5dd0c1..435fee8 100644 --- a/features/drupalorg_content_types/drupalorg_content_types.strongarm.inc +++ b/features/drupalorg_content_types/drupalorg_content_types.strongarm.inc @@ -702,6 +702,11 @@ function drupalorg_content_types_strongarm() { 'custom-drupalorg_trydrupal_button' => TRUE, 'block-block-56' => TRUE, 'block-google_admanager-89caa04f148acdc52719b3d001e487c4' => TRUE, + 'block-menu-menu-og-2802989' => TRUE, + 'block-menu-menu-documentation' => TRUE, + 'block-menu-menu-og-2734545' => TRUE, + 'block-menu-menu-og-2827275' => TRUE, + 'block-message_follow-follow' => TRUE, 'block-og_menu-og_single_menu_block' => TRUE, 'block-og_menu-og_multi_menu_block' => TRUE, 'fieldable_panels_pane-cta' => TRUE, -- 2.1.4