Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /**
|
Chris@0
|
4 * @file
|
Chris@0
|
5 * {{ plugin_name }} relationship plugin.
|
Chris@0
|
6 */
|
Chris@0
|
7
|
Chris@0
|
8 /**
|
Chris@0
|
9 * Plugin definition.
|
Chris@0
|
10 */
|
Chris@0
|
11 $plugin = array(
|
Chris@0
|
12 'title' => t('{{ plugin_name }}'),
|
Chris@0
|
13 'description' => t('{{ description }}'),
|
Chris@0
|
14 {% if context == 'Node' or context == 'User' %}
|
Chris@4
|
15 'required context' => new ctools_context_required(t('{{ context }}'), '{{ context|lower }}'),
|
Chris@0
|
16 {% elseif context == 'Term' %}
|
Chris@0
|
17 'required context' => new ctools_context_required(t('{{ context }}'), array('term', 'taxonomy_term')),
|
Chris@0
|
18 {% endif %}
|
Chris@0
|
19 'context' => '{{ machine_name }}_{{ plugin_machine_name }}_context',
|
Chris@0
|
20 );
|
Chris@0
|
21
|
Chris@0
|
22 /**
|
Chris@0
|
23 * Returns a new context based on an existing context.
|
Chris@0
|
24 */
|
Chris@0
|
25 function {{ machine_name }}_{{ plugin_machine_name }}_context($context, $conf) {
|
Chris@0
|
26
|
Chris@0
|
27 // @TODO: Replace "node" with identifier of the context
|
Chris@0
|
28 // this plugin is meant to provide.
|
Chris@0
|
29 if (empty($context->data)) {
|
Chris@0
|
30 return ctools_context_create_empty('node', NULL);
|
Chris@0
|
31 }
|
Chris@0
|
32
|
Chris@0
|
33 {% if context == 'Node' or context == 'Term' %}
|
Chris@4
|
34 ${{ context|lower }} = clone $context->data;
|
Chris@0
|
35
|
Chris@0
|
36 {% elseif context == 'User' %}
|
Chris@0
|
37 {# Use $account variable avoid confusion with the global $user object #}
|
Chris@0
|
38 $account = clone $context->data;
|
Chris@0
|
39
|
Chris@0
|
40 {% endif %}
|
Chris@0
|
41 // @TODO: Replace this code with your own.
|
Chris@0
|
42 $related_node = node_load(1);
|
Chris@0
|
43 return ctools_context_create('node', $related_node);
|
Chris@0
|
44 }
|