CMS  Version 3.9
TaxonomyHelper Class Reference

Static Public Member Functions

static formatAssociatedTerms ($taxonomy_identifier, $obj, $separator=", ")
 Given a taxonomy identifier and an obj, return the associated terms. More...
 
static decorate ($item, $separator=", ")
 Decorates the target DataItem with all the associated taxonomy terms. More...
 

Detailed Description

Definition at line 39 of file taxonomy_helper.inc.

Member Function Documentation

◆ decorate()

static TaxonomyHelper::decorate (   $item,
  $separator = ", " 
)
static

Decorates the target DataItem with all the associated taxonomy terms.

Parameters
DataItem$itemthe target DataItem
string$separatorthe separator to use when formatting multiple taxonomy terms

Definition at line 64 of file taxonomy_helper.inc.

65  {
67 
68  foreach($taxonomies as $taxonomy)
69  {
70  $item->decorate($taxonomy->identifier, TaxonomyHelper::formatAssociatedTerms($taxonomy->identifier, $item, $separator));
71  }
72  }
$taxonomies
Definition: taxonomies.inc:39
static formatAssociatedTerms($taxonomy_identifier, $obj, $separator=", ")
Given a taxonomy identifier and an obj, return the associated terms.
static getAssociatedTaxonomies($classes, $facet_filter_only=false)

◆ formatAssociatedTerms()

static TaxonomyHelper::formatAssociatedTerms (   $taxonomy_identifier,
  $obj,
  $separator = ", " 
)
static

Given a taxonomy identifier and an obj, return the associated terms.

Parameters
String$taxonomy_identifier
obj$objDataItem object associated with the taxonomy
Returns
string

Definition at line 48 of file taxonomy_helper.inc.

49  {
50  $pk = $obj->getPrimaryKey();
51 
52  $terms = Query::create(TaxonomyTerm, "WHERE term_id IN (SELECT term_id FROM taxonomy_term_association WHERE class=:class AND id=:obj_id AND taxonomy_id IN (SELECT taxonomy_id FROM taxonomy WHERE identifier=:identifier)) AND taxonomy_id IN (SELECT taxonomy_id FROM taxonomy WHERE identifier=:identifier) ORDER BY term")
53  ->bind(":class", get_class($obj), ":obj_id", $obj->get($pk), ":identifier", $taxonomy_identifier)
54  ->execute();
55 
56  return formatItems($terms, "{term}", $separator);
57  }

The documentation for this class was generated from the following file: