Drupal $tabs 不包括编辑/修订/工作流程

2021-12-29 00:00:00 tabs php drupal menu drupal-5

我继承了一个 Drupal5 站点,并负责进行一些更改,但我不知道从哪里开始查找.

I inherited a Drupal5 site and have been tasked with making some changes, but I'm unable to figure out where to start looking.

在许多页面上都有一个可供管理员使用的菜单,允许您执行某些操作:

On many pages there is a menu available to administrators that allows you do do certain actions:

概览专家资源和工具在该领域消息活动培训班多媒体编辑追踪工作流程设置

Overview Specialists Resources and Tools In the Field News Events Courses Multimedia Edit Track Workflow Settings

但是,在某些部分,有不同的选项:预览布局设置布局设置先进的语境内容导出

However, on some sections, there are different options: Preview Layout Settings Layout settings Advanced Context Content Export

我需要将(编辑、跟踪、工作流程、设置)添加到第二个菜单中,但我不知道该怎么做.

I need to add (Edit, Track, Workflow, Settings) to the second menu, but I'm not sure how to do that.

我在 page.tpl.php 中看到 $tabs 的区域,但我不知道它是如何构建的.

I see in page.tpl.php there is region for $tabs, but I can't figure out how this gets built.

据我所知,该主题基于 Zen STARTERKIT 主题.

From what I can tell, the theme is based on the Zen STARTERKIT theme.

推荐答案

$tabs 变量通常填充 MENU_LOCAL_TASK 类型的菜单条目.

The $tabs variable normally gets populated with menu entries of type MENU_LOCAL_TASK.

查看菜单系统,尤其是hook_menu() 以获得基本概念.它归结为回调函数到路径的映射.如果 URL 与 hook_menu 中定义的路径匹配(可以包含占位符!),将为该路径注册的回调函数将被调用以生成该 URL 的内容.

Take a look at the menu system, and especially at hook_menu() to get a basic idea. It boils down to a mapping of callback functions to paths. If an URL matches a path defined in hook_menu (can contain placeholders!), the callback function registered for that path will be called to generate the content for that URL.

hook_menu 项的类型"定义了路径/回调组合在系统中的表示方式.它可以是 MENU_CALLBACK,这意味着只是注册的路径/回调组合,但没有相应的真实"菜单条目.MENU_NORMAL_ITEM,将是相同的,但具有标准"菜单条目,例如在导航菜单中.MENU_LOCAL_TASK 是相同的,但相应的菜单条目通常显示在 $tabs 中而不是菜单中.

The 'type' of the hook_menu item defines how the path/callback combination is represented in the system. It can be a MENU_CALLBACK, which would mean just the registered path/callback combination, but no corresponding 'real' menu entry. A MENU_NORMAL_ITEM, would be the same, but with a 'standard' menu entry, e.g. in the navigation menu. A MENU_LOCAL_TASK is the same, but the corresponding menu entry usually shows up in the $tabs and not in a menu.

共享相同基本路径的所有 MENU_LOCAL_TASK 最终将成为一组选项卡.所以如果你有这样的路径:

All MENU_LOCAL_TASK that share the same base path will end up as a group of tabs. So if you had paths like:

  • some/path/tab1
  • some/path/tab2
  • some/path/tab3

并且所有这些都定义为MENU_LOCAL_TASK,您会在它们代表的每个页面上看到每个标签.

and all of these where defined as MENU_LOCAL_TASK, you would see one tab for each of them on each page they represent.

因此,要找到需要修改/增强的位置,您应该在代码库中搜索所有 hook_menu() 实现,这些实现定义了这些选项卡显示的路径.请注意,它们不需要全部定义在同一位置,但可以来自不同模块中的不同 hook_menu 实现.比您需要为要添加的选项卡添加菜单定义,将相关路径映射到回调函数.回调函数将返回用户点击标签时应该看到的页面内容.

So to find the places you need to modify/enhance, you should search your codebase for all hook_menu() implementations that define the paths where those tabs show up. Note that they need not all be defined at the same place, but could come from different hook_menu implementations in different modules. Than you'd need to add menu definitions for the tabs you want to add, mapping the relevant paths to callback functions. The callback functions would return the content of the pages that the user should see when clicking the tabs.

相关文章