You are here

function _dfp_get_ad_category in Doubleclick for Publishers (DFP) 7

Same name and namespace in other branches
  1. 7.2 dfp.module \_dfp_get_ad_category()

Return the term object to use as the DFP Ad Category given a specific term.

Parameters

object $term: The term object to analyze. If it is tagged with a DFP Ad Cateegory, then that term is returned, otherwise the original term is returned unchanged.

boolean $clean_string: If true, use ctools_cleanstring. In future versions, this should default to TRUE, but for now it defaults to FALSE.

Return value

string The term name to be included in an ad tag.

1 call to _dfp_get_ad_category()
dfp_entity_view in ./dfp.module
Implements hook_entity_view().

File

./dfp.module, line 643

Code

function _dfp_get_ad_category($term, $clean_string = FALSE) {
  if (!empty($term->field_dfp_ad_categories)) {
    $term = taxonomy_term_load($term->field_dfp_ad_categories[LANGUAGE_NONE][0]['tid']);
  }
  $term_name = $term->name;
  if ($clean_string) {
    ctools_include('cleanstring');
    $term_name = ctools_cleanstring($term_name, array(
      'lower_case' => TRUE,
    ));
  }
  return $term->name;
}