gpt4 book ai didi

drupal - 如何更改 Drupal 中的 MENU_LOCAL_TASK 选项卡菜单

转载 作者:行者123 更新时间:2023-12-03 22:45:02 24 4
gpt4 key购买 nike

我在我的自定义 Drupal 6 模块中构建了一个选项卡式菜单。我想在模块页面顶部的选项卡式菜单右侧放置一个 html 下拉列表。该列表将在更改时触发一些 ajax 事件,例如通过指定 10,20,50,100 个结果来更改 SQL 查询的 LIMIT 子句。我怎样才能在 Drupal 中实现这一点而无需破解模板?

谢谢,

最佳答案

您可以通过覆盖 theme_menu_local_tasks() 来做到这一点。在您的主题中:

function yourTheme_menu_local_tasks() {
// Prepare empty dropdown to allow for unconditional addition to output below
$dropdown = '';
// Check if the dropdown should be added to this menu
$inject_dropdown = TRUE; // TODO: Add checking logic according to your needs, e.g. by inspecting the path via arg()
// Injection wanted?
if ($inject_dropdown) {
// Yes, build the dropdown using Forms API
$select = array(
'#type' => 'select',
'#title' => t('Number of results:'),
'#options' => array('10', '20', '50', '100'),
);
// Wrap rendered select in <li> tag to fit within the rest of the tabs list
$dropdown = '<li>' . drupal_render($select) . '</li>';
}

// NOTE: The following is just a copy of the default theme_menu_local_tasks(),
// with the addition of the (possibly empty) $dropdown variable output
$output = '';
if ($primary = menu_primary_local_tasks()) {
$output .= "<ul class=\"tabs primary\">\n". $primary . $dropdown . "</ul>\n";
}
if ($secondary = menu_secondary_local_tasks()) {
$output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
}

return $output;
}

(注意:未经测试的代码 - 潜在的拼写错误)

关于drupal - 如何更改 Drupal 中的 MENU_LOCAL_TASK 选项卡菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1826668/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com