I am not sure if this is a Panels or CTools problem, but I have a Panels/CTools content type configured like this:

function ding_campaign_relevant_content_type_content_types() {
  $types = array(
    'relevant_campaigns' => array(
      'title' => t('Relevant campaigns'),
      'category' => t('Miscellaneous'),
      'required context' => array(
        new ctools_context_optional(t('Page node'), 'node'), 
        new ctools_context_optional(t('Related library'), 'node'),
      ),
    ),
  );
  return $types;
}

This works beautifully as long as the content type receives one or both of these contexts – but if it receives neither, the content type is not rendered (makes sense, since the context is supposed to be required).

Now, according to panels/docs/sample_plugin_ct.inc, line 289-294, there is a similar property called 'optional context', but if I try to use that instead of 'required context', the contexts stop working at all, not being passed to the rendering function and not appearing in the panels admin (If you have multiple nodes and/or context that receive them, selectors appear to let you pick which one goes where).

Comments

merlinofchaos’s picture

I'm not sure if this is a problem in beta4 or not. I made a fix to contexts that was preventing certain things from working correctly, but this problem sounds a little different. Can you update to beta4 and let me know if this problem still exists?

mikl’s picture

Version: 6.x-3.0-beta2 » 6.x-3.0-beta4

Yes, I've seen no change in the described problem after upgrading to beta4 of both Panels and CTools. The 'optional context' parameter does not appear to work (not with an array, anyways), and 'required context' still requires one of the contexts to be present, even if both are ctools_context_optional.

merlinofchaos’s picture

Project: Panels » Chaos Tool Suite (ctools)
Version: 6.x-3.0-beta4 » 6.x-1.x-dev
Component: Plugins - content types » Code

This actually is a CTools issue.

Right now the optional contexts are not being properly excluded when testing to see if context requirements are met.

merlinofchaos’s picture

Status: Active » Fixed

Oh, the 'optional context' property doesn't exist. I think that was an error in the sample. That sample hasn't been cleaned up at all.

I *think* I have htis fixed, but I don' thave a really good test content type for this to try.

mikl’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc1

Yes, I can confirm it as fixed as in RC1, thanks.

Status: Fixed » Closed (fixed)

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