45 lines
1.2 KiB
Twig
45 lines
1.2 KiB
Twig
<?php
|
|
|
|
/**
|
|
* @file
|
|
* {{ plugin_name }} relationship plugin.
|
|
*/
|
|
|
|
/**
|
|
* Plugin definition.
|
|
*/
|
|
$plugin = array(
|
|
'title' => t('{{ plugin_name }}'),
|
|
'description' => t('{{ description }}'),
|
|
{% if context == 'Node' or context == 'User' %}
|
|
'required context' => new ctools_context_required(t('{{ context }}'), '{{ context|lower }}'),
|
|
{% elseif context == 'Term' %}
|
|
'required context' => new ctools_context_required(t('{{ context }}'), array('term', 'taxonomy_term')),
|
|
{% endif %}
|
|
'context' => '{{ machine_name }}_{{ plugin_machine_name }}_context',
|
|
);
|
|
|
|
/**
|
|
* Returns a new context based on an existing context.
|
|
*/
|
|
function {{ machine_name }}_{{ plugin_machine_name }}_context($context, $conf) {
|
|
|
|
// @TODO: Replace "node" with identifier of the context
|
|
// this plugin is meant to provide.
|
|
if (empty($context->data)) {
|
|
return ctools_context_create_empty('node', NULL);
|
|
}
|
|
|
|
{% if context == 'Node' or context == 'Term' %}
|
|
${{ context|lower }} = clone $context->data;
|
|
|
|
{% elseif context == 'User' %}
|
|
{# Use $account variable avoid confusion with the global $user object #}
|
|
$account = clone $context->data;
|
|
|
|
{% endif %}
|
|
// @TODO: Replace this code with your own.
|
|
$related_node = node_load(1);
|
|
return ctools_context_create('node', $related_node);
|
|
}
|