.../modules/contrib/ctools/plugins/contexts/terms.inc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sites/all/modules/contrib/ctools/plugins/contexts/terms.inc b/sites/all/modules/contrib/ctools/plugins/contexts/terms.inc index 6c3ab36..661101b 100644 --- a/sites/all/modules/contrib/ctools/plugins/contexts/terms.inc +++ b/sites/all/modules/contrib/ctools/plugins/contexts/terms.inc @@ -25,6 +25,7 @@ $plugin = array( 'name_dashed' => t('Term name of first term, lowercased and spaces converted to dashes'), 'names' => t('Term name of all terms, separated by + or ,'), 'names_dashed' => t('Term name of all terms, separated by + or , and lowercased and spaces converted to dashes'), + 'names_dashed_spaces' => t('Term name of all terms lowercased and spaces converted to dashes, separated by spaces'), 'vid' => t('Vocabulary ID of first term'), ), 'convert' => 'ctools_context_terms_convert', @@ -92,6 +93,24 @@ function ctools_context_terms_convert($context, $type) { } } return $context->names; + case 'names_dashed_spaces': + // We only run this query if this item was requested: + if (!isset($context->names)) { + if (empty($context->tids)) { + $context->names = ''; + } + else { + $result = db_query('SELECT tid, name FROM {taxonomy_term_data} WHERE tid IN (:tids)', array(':tids' => $context->tids)); + foreach ($result as $term) { + $names[$term->tid] = $term->name; + if ($type == 'names_dashed_spaces') { + $names[$term->tid] = drupal_strtolower(str_replace(' ', '-', $names[$term->tid])); + } + } + $context->names = implode(' ', $names); + } + } + return $context->names; case 'vid': return $context->data->vid; }