Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi guys!
I have included a module REALNAME and found that the page type / blog /% user turn off the panel.
I found a similar issue in the topic, but they do not directly solve the problem with page_manager type blog.
This code overrides the function call($callbacks[$path]['page callback'] = 'realname_blog_page';), and it will lock page_manager
/**
* Implements hook_menu_alter().
*/
function realname_menu_alter(&$callbacks) {
$callbacks['user/%user_uid_optional']['title callback'] = 'realname_user_page_title';
// Adjust menu page callbacks to the real name alternatives.
foreach ($callbacks as $path => $callback) {
if (isset($callback['page callback'])) {
switch ($callback['page callback']) {
case 'user_view':
// Skip if the Page manager module is installed, which needs to
// override
if ($path == 'user/%user_uid_optional' && module_exists('page_manager') && !variable_get('page_manager_user_view_disabled', TRUE)) {
continue;
}
case 'user_edit':
case 'tracker_page':
case 'statistics_user_tracker':
case 'content_profile_page_edit':
$callbacks[$path]['page callback'] = 'realname_' . $callback['page callback'];
break;
case 'contact_user_page':
$callbacks[$path]['page callback'] = 'realname_contact_user';
break;
case 'blog_page_user':
$callbacks[$path]['page callback'] = 'realname_blog_page';
break;
}
................
//$callbacks[$path]['page callback'] = 'realname_blog_page';
If you disable this override will be called:
/**
* Entry point for our overridden user view.
*
* This function asks its assigned handlers who, if anyone, would like
* to run with it. If no one does, it passes through to Drupal core's
* user view, which is user_page_view().
*/
function page_manager_blog_user($account) {
// Load my task plugin:
$task = page_manager_get_task('blog_user');
// Load the account into a context.
ctools_include('context');
ctools_include('context-task-handler');
$contexts = ctools_context_handler_get_task_contexts($task, '', array($account));
$output = ctools_context_handler_render($task, '', $contexts, array($account->uid));
if ($output !== FALSE) {
return $output;
}
module_load_include('inc', 'blog', 'blog.pages');
$function = 'blog_page_user';
foreach (module_implements('page_manager_override') as $module) {
$call = $module . '_page_manager_override';
if (($rc = $call('blog_user')) && function_exists($rc)) {
$function = $rc;
break;
}
}
// Otherwise, fall back.
return $function($account);
}
In realname implemented hook_page_manager_override but you need to add some changes:
/**
* Ask Page Manager to use our version of the node page view instead of
* Drupal's when falling back.
*/
function realname_page_manager_override($type) {
dpm($type);
if ($type == 'user_view') {
return 'realname_user_view';
+ } elseif ($type == 'blog_user') {
+ return 'realname_blog_user';
+ }
}
and
+function realname_blog_user($account) {
+ $output = blog_page_user($account);
+ drupal_set_title(t("@name's blog", array('@name' => $account->realname)));
+ return $output;
+}
Comments
Comment #1
darkdimComment #2
darkdimsorry
Forgot the situation when the page manager is not enabled.
Comment #3
darkdimComment #4
hass CreditAttribution: hass commented