class context_reaction_template_suggestions in Context 7.3
Add template suggestions as a context reaction.
Hierarchy
- class \context_reaction
Expanded class hierarchy of context_reaction_template_suggestions
2 string references to 'context_reaction_template_suggestions'
- _context_context_plugins in ./
context.plugins.inc - Context plugins.
- _context_context_registry in ./
context.plugins.inc - Context registry.
File
- plugins/
context_reaction_template_suggestions.inc, line 6
View source
class context_reaction_template_suggestions extends context_reaction {
/**
* Display the text area field for adding new template suggestions.
*/
function options_form($context) {
$default_value = $this
->fetch_from_context($context);
return array(
'#title' => t('Template suggestions'),
'#type' => 'textarea',
'#description' => t('Enter template suggestions such as "page__front", one per line, in order of preference (using underscores instead of hyphens). For more information, please visit <a href="@template-suggestions">Drupal 7 Template (Theme Hook) Suggestions</a>.', array(
'@template-suggestions' => 'http://drupal.org/node/1089656',
)),
'#default_value' => is_string($default_value) ? $default_value : '',
);
}
/**
* Add any new template suggestions to the current list.
*/
function execute(&$vars = NULL) {
// Get the list of contexts associated with this reaction.
$contexts = $this
->get_contexts();
// Iterate through each, and process those with something set.
foreach ($contexts as $context) {
if (isset($context->reactions) && !empty($context->reactions[$this->plugin])) {
// Get the suggestion data entered by the user.
$suggestions = $this
->fetch_from_context($context, 'values');
// Convert it to an list and reverse it (as higher priority items
// should be on the bottom).
$suggestions = array_reverse(explode("\n", $suggestions));
// Append the suggested list to the existing list.
$vars['theme_hook_suggestions'] = array_merge($vars['theme_hook_suggestions'], $suggestions);
}
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
context_reaction:: |
property | |||
context_reaction:: |
property | |||
context_reaction:: |
property | |||
context_reaction:: |
function | Retrieve options from the context provided. | 1 | |
context_reaction:: |
function | Retrieve active contexts that have values for this reaction. | ||
context_reaction:: |
function | Options form submit handler. | 3 | |
context_reaction:: |
function | Settings form. Provide variable settings for your reaction. | 2 | |
context_reaction:: |
function | Clone our references when we're being cloned. | ||
context_reaction:: |
function | Constructor. Do not override. | ||
context_reaction_template_suggestions:: |
function | Add any new template suggestions to the current list. | ||
context_reaction_template_suggestions:: |
function |
Display the text area field for adding new template suggestions. Overrides context_reaction:: |