Hi,
I want to store a manually created variant (via page manager UI) for an activated system page (e.g. node_view which refers to path '/node/%node') in my module code. But I can't figure out the hook and the syntax where I have to place such code - and I even can't find a working export option for my manually created variant (which "lives" in database - that means storage type is 'Normal') in the admin area for my system page.
Or an even better option for me would be an opportunity to "recycle" a variant defined for one system (or custom) page in another system (or custom) page (in code and not via UI). E.g. I want to define a variant once (this could be done manually or in code) for '/node/%node' and I want to re-use the same variant for path '/node/%node/revisions/%/view'. (And I don't want to use the Export / Import functionality after each change. I need some automated solution.)
Thanks in advance.
------------------------------
I found how to store manually created variants in code for custom pages (e.g. '/node/%node/test')
function MODULE_default_page_manager_pages() {
// Copy exported page code here.
$pages['UNIQUE_PAGE_ID_HERE'] = $page;
return $pages;
}
Putting everthing in a file called 'MODULE.pages_default.inc' and link that file with my MODULE.module via
/**
* Implement hook_ctools_plugin_api().
*
* If you do this, CTools will pick up default panels pages in
* MODULE.pages_default.inc
*/
function MODULE_ctools_plugin_api($module, $api) {
if ($module == 'page_manager' && $api == 'pages_default') {
return array('version' => 1);
}
}I try to find an analog solution for system pages.
Thanks,
Martin
Comments
Comment #1
m_z commentedI think that I found the solution - maybe it can help others or please post if you have a better solution.
System pages are defined in /plugins/tasks/TASK-HANDLER-NAME.inc files.
I started my modifications (for "my" node_revision_view.inc) based on node_view.inc which comes with CTools.
In that .inc file you have to define a function MODULENAME_TASK-HANDLER-NAME_page_manager_tasks() which returns an array.
In that array I added a key: 'default handlers' => SOME-FUNCTION-NAME(),
Last step is the definition of a function which returns the default handlers:
After uploading my modified .inc file I can find the "code generated" variant in my panel page.
And it works :-))
Comment #2
merlinofchaos commentedYeah. For an easy way to see how to do all that, use the bulk export tool and export your handler. I suppose the downside here is that it might not be clear that a 'task handler' is a 'variant' in the UI.
Comment #3
m_z commented@merlinofchaos: Thank you for bringing bulk export tool on my radar.
Testing this tool I found out that hook_default_page_manager_handlers() which has to be placed in MODULENAME.pages_default.inc.
Maybe the ctools_plugin_example should include an implementation of this hook (because I couldn't find it in any documentation about Panels - up to now only 2 hits if looking for this hook at drupal.org search).
Is there an overview about Panel 3 hooks anywhere available?
Comment #5
andrewbelcher commentedI just came across the same, if you want an example, OG contains a module, og_example, which implements this...