You are here

function _ed_classified_get_primary_category in Classified Ads 6.2

Same name and namespace in other branches
  1. 5.2 ed_classified_utils.inc \_ed_classified_get_primary_category()
  2. 5 ed_classified_utils.inc \_ed_classified_get_primary_category()
  3. 7.2 ed_classified_utils.inc \_ed_classified_get_primary_category()

Helper function to determine the single ad category name to which this node belongs.

1 call to _ed_classified_get_primary_category()
theme_ed_classified_ads_block in ./ed_classified_themefuncs.inc
Theme an ads block

File

./ed_classified_utils.inc, line 71
Simple text-based classified ads module.

Code

function _ed_classified_get_primary_category($node) {

  // lifted from _nodeapi implementation - crude, need to find out if there's a better way to get the single term for this node.
  $terms = taxonomy_node_get_terms_by_vocabulary($node, _ed_classified_get_vid());
  $term = array_pop($terms);
  if ($term) {
    $vocabulary = taxonomy_vocabulary_load(_ed_classified_get_vid());
    if ($parents = taxonomy_get_parents_all($term->tid)) {
      return $parents[0];
    }
  }
  return 0;
}