دروپال
نمایش زیر منوها در قالب دلخواه

به طور پیش فرض زیر منوها در قالب دلخواه شما تنها با انتخاب گزینه Show as expanded در منوی والد نمایش داده نمی شوند انتخاب این گزینه تنها در تم پیش فرض دروپال مانند bartik و با جابه جا کردن بلوک منو در یک ناحیه جدا قابل نمایش است .
بدین منظور علاوه بر زدن تیک Show as expanded در منوی والد قطعه کد زیر را در فایل template.php در ساب تم مورد نظر خود قرار داده :
1 2 3 4 5 6 7 |
function YOURTHEME_preprocess_page(&$variables) { // Get the entire main menu tree $main_menu_tree = menu_tree_all_data('main-menu'); // Add the rendered output to the $main_menu_expanded variable $variables['main_menu_expanded'] = menu_tree_output($main_menu_tree); } |
سپس به جای قرار دادن قطعه کد زیر برای نمایش منو روی صفحه , در page.tpl تم مورد نظر :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php if ($main_menu): ?> <nav id="main-menu" role="navigation" tabindex="-1"> <?php // This code snippet is hard to modify. We recommend turning off the // "Main menu" on your sub-theme's settings form, deleting this PHP // code block, and, instead, using the "Menu block" module. // @see https://drupal.org/project/menu_block print theme('links__system_main_menu', array( 'links' => $main_menu, 'attributes' => array( 'class' => array('links', 'inline', 'clearfix'), ), 'heading' => array( 'text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'), ), )); ?> </nav> <?php endif; ?> |
تنها با نوشتن یک خط دستور در page.tpl , منو به همراه تمام زیر منو ها نمایش داده می شوند :
1 |
<?php print render($main_menu_expanded); ?> |
در آخر با دادن css مناسب منوی دلخواه خود را طراحی نمایید.
برگرفته از: لینک