summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2010-11-01 20:40:39 (GMT)
committer Earl Miles2010-11-01 20:40:39 (GMT)
commit2cf31e53a7e9c6419e44dc79db35e07f365f589e (patch)
tree4d9725596b5674b96135bbabfd05d9a5356e93a4
parent36d1ff198eed93db9cee28843ecc71a67429d312 (diff)
#959206: If a context is not set when rendering content, attempt to guess the context (fixes Views panes where "From context" was added but pane was never edited.)
-rw-r--r--CHANGELOG.txt2
-rw-r--r--includes/content.inc29
2 files changed, 30 insertions, 1 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index cfd80c3..9092fd0 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -27,4 +27,4 @@ Variant titles showing up as blank if more than one variant on a page.
#954728 by EclipseGc: Update node template page function name to not collide with new hook_node_view().
#946534 by EclipseGc: Add support for field content on all entitities.
#952586 by EclipseGc: Fix node_author content type.
-
+#959206: If a context is not set when rendering content, attempt to guess the context (fixes Views panes where "From context" was added but pane was never edited.)
diff --git a/includes/content.inc b/includes/content.inc
index df38dc6..69f9e1c 100644
--- a/includes/content.inc
+++ b/includes/content.inc
@@ -735,6 +735,35 @@ function ctools_content_select_context($plugin, $subtype, $conf, $contexts) {
return;
}
+ // Deal with dynamic required contexts not getting updated in the panes.
+ // For example, Views let you dynamically change context info. While
+ // we cannot be perfect, one thing we can do is if no context at all
+ // was asked for, and then was later added but none is selected, make
+ // a best guess as to what context should be used. THis is right more
+ // than it's wrong.
+ if (is_array($subtype_info['required context'])) {
+ if (empty($conf['context']) || count($subtype_info['required context']) != count($conf['context'])) {
+ foreach($subtype_info['required context'] as $index => $required) {
+ if (!isset($conf['context'][$index])) {
+ $filtered = ctools_context_filter($contexts, $required);
+ if ($filtered) {
+ $keys = array_keys($filtered);
+ $conf['context'][$index] = array_shift($keys);
+ }
+ }
+ }
+ }
+ }
+ else {
+ if (empty($conf['context'])) {
+ $filtered = ctools_context_filter($contexts, $subtype_info['required context']);
+ if ($filtered) {
+ $keys = array_keys($filtered);
+ $conf['context'] = array_shift($keys);
+ }
+ }
+ }
+
if (empty($conf['context'])) {
return;
}