Pretty sure this set of changes allowed me to pass empty optional contexts to context views so that a single view could be used as a context and optionally consume taxonomy term or user id and provide appropriate blogs for that. Very useful. Apparently there was some sort of bug in the uid argument when I did it as well.

Issue fork ctools-1276000

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

EclipseGc’s picture

FileSize
2.9 KB
EclipseGc’s picture

FileSize
3.13 KB

An update to this. This should version of the patch will actually add a NULL spacer into the context where it should exist, so if a plugin takes 3 contexts, the first is required the next 2 are optional, and you only pass the second you'd still have a NULL context in place of the optional context you didn't pass. This allows modules like views to expect to get all the contexts they can address, and we rely on the argument handling to return the view properly at that point.

This will need some further testing, but I don't anticipate it causing issues for existing plugins.

merlinofchaos’s picture

Status: Needs review » Needs work

I believe this may be fixed by #1263896: "context exists" access plugin broken (patch) instead?

EclipseGc’s picture

Status: Needs work » Needs review
FileSize
3.16 KB

This patch is about allowing empty contexts to exist for views that take optional contexts. The other patch being present didn't seem to have any bearing on this as far as I could tell.

Eclipse

EclipseGc’s picture

Rerolled against 7.x-1.x.

EclipseGc’s picture

FileSize
4.09 KB

This is better, it actually works for NULL contexts that are the first argument.

DamienMcKenna’s picture

Assigned: EclipseGc » Unassigned
Issue summary: View changes

DamienMcKenna queued 6: 1276000-6.patch for re-testing.

geek-merlin’s picture

Crosslinking 2 other issues with nearly the same patch. We should really consolidate that.

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 6 year old patch in #6 does not apply to the latest ctools 7.x-1.x-dev.

Checking patch includes/context.inc...
Hunk #1 succeeded at 1416 (offset 422 lines).

Checking patch includes/context.theme.inc...
Hunk #1 succeeded at 215 (offset -1 lines).

Checking patch views_content/plugins/relationships/view_from_argument.inc...
error: while searching for:
  $name = $conf['name'];
  list($plugin, $view_data) = explode(':', $name);
  list($view_name, $display_id) = explode('-', $view_data);
  $keys = array_keys($conf['context']);

  if (empty($contexts[$keys[0]]->data)) {
    return ctools_context_create_empty('view', NULL);
  }

  // Load our view up.
  $data = views_get_view($view_name);
  if ($data) {
    // Set the display.
    $data->set_display($display_id);
    $context_keys = array_keys($contexts);
    foreach ($data->display_handler->get_argument_input() as $id => $argument) {
      if ($argument['type'] == 'context') {
        $key = array_shift($context_keys);
        if (isset($contexts [$key])) {
          if (strpos($argument['context'], '.')) {
            list($context, $converter) = explode('.', $argument['context'], 2);
            $args[] = ctools_context_convert_context($contexts[$key], $converter, array('sanitize' => FALSE));
          }
          else {
            $args[] = $contexts[$key]->argument;
          }
        }
      }
    }
    // remove any trailing NULL arguments as these are non-args:

error: patch failed: views_content/plugins/relationships/view_from_argument.inc:58
error: views_content/plugins/relationships/view_from_argument.inc: patch does not apply
shubham.prakash’s picture

Status: Needs work » Needs review
FileSize
4.09 KB
DamienMcKenna’s picture

Issue tags: -Needs reroll
joelpittet’s picture

Issue tags: +Needs reroll

I committed #2399313: Relationship silently left out if it has optional required context so this needs another reroll. Also that might have helped solve part of what this patch is trying to do.

adityasingh’s picture

Issue tags: -Needs reroll
FileSize
3.4 KB

Reroll the patch.

xlin made their first commit to this issue’s fork.