dpd3447 2013-09-29 22:29
浏览 25
已采纳

Drupal 7节点引用“查询”

I have a content type called services_list_page that is used to create a landing page that people can then use to navigate to child pages using the content type service_details. The relationship between these pages is only defined by a menu and no where else currently.

Program Service (services_list_page)
-- Cat1: (not a page, just a category type thing in menu)
  -- child 1 (service_details)
  -- child 2 (service_details)
-- Cat2
  -- child 3
  -- child4
  -- and so on..

I need to have these child pages not only listed in the menu but also dynamically within the content in lists (ul li) one list per child page "category". I have overridden the node template file for these content types. What would the best way to do this with either a module or some code within the template file to pull this data dynamically?

  • 写回答

2条回答 默认 最新

  • dongpanshi2839 2013-10-05 09:26
    关注

    Found an easy solution So at first I found a way to get by but it was messy and the in page menus did not get updated when the left nav sub menu was updated. Then I found the menu block module.

    • Install Menu Block Module https://drupal.org/project/Menu_Block
    • add new menu block, configure as needed. starting level set to second level
    • Add the following code to template file to invoke the menu block

    You can get the number, in here its 1, from the url when you click configure for the menu block on the block page, so admin/structure/block/manage/menu_block/1/configure becomes:

    $block = module_invoke('menu_block', 'block_view', '1');
    print render($block['content']);
    
    • Optional Create template for the menu by creating template file "menu-block-wrapper--1.tpl.php". you can get the menu data by looping through the array called $content
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?