Taxonomy Section Custom Drupal Code

  1. $taxo_section_string = $taxo_section;
  2. echo "[" . $taxo_section_string . "]";
  3. $taxo_section_tids = taxonomy_get_term_by_name($taxo_section_string);
  4. if (!$taxo_section_tids) {
  5. // add section into this issue
  6. // this will only occur with new section names
  7. $form_values = array('vid' => $taxo_volume_vid, 'name' => $taxo_section_string, 'parent' => array($taxo_issue_tid));
  8. $status = taxonomy_save_term($form_values);
  9. echo "[added" . $taxo_section_string . "]";
  10. $taxo_section_tids = taxonomy_get_term_by_name($taxo_section_string);
  11. foreach ($taxo_section_tids as $item) {
  12. $this_taxo_section_tid = $item->tid;
  13. echo "[addedONsecTID" . $this_taxo_section_tid . "]";
  14. $this_parent_tids = taxonomy_get_parents($this_taxo_section_tid);
  15. foreach ($this_parent_tids as $this_parent_tid) {
  16. if ($this_parent_tid->tid == $taxo_section_tid) {
  17. $taxo_section_tid = $this_taxo_section_tid;
  18. echo "[addedmatchPar" . $this_parent_tid->tid . "]";
  19. }
  20. }
  21. }
Original location: 

none