Page manager module is unable to enable node/%node because some other module already has overridden with commons_core_node_page_view.

because commons_core.module does this:

// Override the node view callback in order to handle group home pages
  $items['node/%node']['page callback'] = 'commons_core_node_page_view';
  $items['node/%node']['file'] = 'commons_core.overrides.inc';
  $items['node/%node']['file path'] = $path;

it does this:

function commons_core_node_page_view($node) {
  // If this node is a group
  if (og_is_group_type($node->type)) {
    // Make context aware of the node view since hook_nodeapi() won't
    // be triggered here
    context_node_condition($node, 'view');
    
    // Return nothing, allowing context to handle the content
    return '';
  }
  
  // Pass the node to the normal callback
  return node_page_view($node);
}

So that prevents Panels from being able to override the node template. What would be a some what easy solution for this?

Comments

mstef’s picture

This probably belongs in the Commons issue queue, right?

merlinofchaos’s picture

Page Manager will not override a menu item if some other item module has already done so. However, it is willing to allow modules to specify what the fallback should be. Modules can test if page manager is active and set to override that page; if it is, they can decline to do so and let Page Manager have it, and Page Manager will pass through to that module if no variant takes it. That's the only way I've found that seems to make cooperation actually work for everyone involved.

The hook is hook_page_manager_override() and its implementation looks like this for node_view:

  $function = 'node_page_view';
  foreach (module_implements('page_manager_override') as $module) {
    $call = $module . '_page_manager_override';
    if (($rc = $call('node_view')) && function_exists($rc)) {
      $function = $rc;
      break;
    }
  }

  // Otherwise, fall back.
  return $function($node);

This should be moved into the commons queue. I'm not quite sure which one that is just now.

mstef’s picture

Project: Panels » Drupal Commons
Version: 6.x-3.9 »
Component: Miscellaneous » Code
Assigned: Unassigned » mstef
mstef’s picture

Category: support » bug
Status: Active » Fixed

Committed for fix for upcoming 2.0.

Came up with an interesting solution that seems fine to me:

/**
 * Implementation of hook_menu_alter()
 */
function commons_core_menu_alter(&$items) {
  $path = drupal_get_path('module', 'commons_core');
  
  // Override the node view callback in order to handle group home pages
  // For legacy support, do not override the node view if page manager
  // is already doing so
  $skip_node_override = FALSE;
  if (module_exists('page_manager')) {
    if ($task = page_manager_get_task('node_view')) {
      if (isset($task['disabled']) && !$task['disabled']) {
        $skip_node_override = TRUE;
      }
    }
  }
  if (!$skip_node_override) {
    $items['node/%node']['page callback'] = 'commons_core_node_page_view';
    $items['node/%node']['file'] = 'commons_core.overrides.inc';
    $items['node/%node']['file path'] = $path;
  }

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

user654’s picture

Title: Node Page View Override Conflicts with Drupal Commons 1.6 » Node Page View Override Conflicts with Drupal Commons 2.2
Status: Closed (fixed) » Active

 

user654’s picture

Could the above fix be included in the next release of Commons?

ezra-g’s picture

Status: Active » Needs work

Could the above fix be included in the next release of Commons?

There are 2 fixes above.

To help get this into Commons, it would be great if someone could test and verify which is the appropriate fix and provide a patch.

mstef’s picture

Wasn't this committed prior to the 2.0 release?

ezra-g’s picture

It's tough to tell without a link to the commit and without user verification of the fix before it was committed.

However, I found https://github.com/acquia/commons/commit/1b5c56f3328a9ff3bdde805c4bf544e... which is the solution in #4.

Based on the pinkonomy's feedback, it sounds like this isn't having the desired effect in Commons 2.2.

Perhaps Merlinofchaos' solution in #2 is the appropriate fix.

monkeythedrummer’s picture

I'm having the same problem. Latest Commons version has the fix in #4, but it is not working properly - I am getting duplicate group images and duplicate featured group checkboxes. How do I test the #2 solution? Just paste it over the non-working one?

mstef’s picture

Status: Needs work » Postponed (maintainer needs more info)

I can confirm that this is working properly, but is easily mistaken as a bug.

First, make sure that your page (in page manager) has been enabled. You can easily add a variant to the node/%node page in page manager, and forget to actually enable the page.

Second, remember that, despite turning on the newly created custom page, the contexts, which power the entire group page, will remain active - so you will get duplicate content. If you don't want the blocks appearing that context provides, be sure to disable them.

After taking that into considering, please retest, and let me know your results.

Thanks.

ezra-g’s picture

Status: Postponed (maintainer needs more info) » Fixed

In my testing I'm able to override the page display for several content types within the latest dev of Commons. Marking this as fixed based on that testing and #12, but please re-open if you're still having issues overriding the node page view with Panels.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.