mtr*_*lle 5 drupal-7 drupal-ctools
我有一个模块,它使用页面管理器模块提供了许多页面hook_default_page_manager_pages()
.这很好.但现在我还想为包含的系统提供一个变体node/%node page
.但我找不到任何提供变种的钩子.
我的问题是,我无法创建自己的页面来覆盖节点/%节点,因为这已经由页面管理器模块本身提供,所以只有我可以创建接管正常节点视图的页面,才能提供变体(根据我的理解).但是我该如何以编程方式执行此操作?我可以看到可以导出变量,因此我猜也可以通过钩子提供它?
这有可能吗?
我找到了我要找的东西.
要为代码中的页面管理器构建页面提供变体,请在模块文件中调用hook_ctools_plugin_api(),让页面管理器知道它应该监听你的模块:
/**
* Implement hook_ctools_plugin_api().
*
* Tells ctools, page manager and panels, that we have a template ready
*/
function mtvideo_ctools_plugin_api($module, $api) {
// @todo -- this example should explain how to put it in a different file.
if ($module == 'panels_mini' && $api == 'panels_default') {
return array('version' => 1);
}
if ($module == 'page_manager' && $api == 'pages_default') {
return array('version' => 1);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,在模块根文件夹中创建一个名为MODULE_NAME.pages_default.inc的新文件.在此文件中,您现在可以包含以下功能:
hook_default_page_manager_pages()
/**
* If you want to put an entire page including its variants in code.
* With the export module from ctools, you can export your whole page to code.
* Paste that into this function.
* (Be aware that the export gives you $page, but you need to return an array,
* So let the function return array('page name' => $page);
*/
Run Code Online (Sandbox Code Playgroud)
和/或
hook_default_page_manager_handlers()
/**
* This will provide a variant of an existing page, e.g. a variant of the system
* page node/%node
* Again, use the export function in Page Manager to export the needed code,
* and paste that into the body of this function.
* The export gives you $handler, but again you want to return an array, so use:
* return array('handler name' => $handler);
*
* Notice, that if you export a complete page, it will include your variants.
* So this function is only to provide variants of e.g. system pages or pages
* added by other modules.
*/
Run Code Online (Sandbox Code Playgroud)
我希望有一天能帮到另一个需要的人:o)我唯一要发现的是我的模块如何以编程方式启用Page Manager中的节点/%节点页面.如果有任何人有线索随意与我分享:)
归档时间: |
|
查看次数: |
3053 次 |
最近记录: |