You are here

function devel_generate_add_terms in Devel 5

Same name and namespace in other branches
  1. 6 devel_generate.inc \devel_generate_add_terms()
  2. 7 devel_generate/devel_generate.inc \devel_generate_add_terms()
1 call to devel_generate_add_terms()
devel_create_nodes in ./devel_generate.inc

File

./devel_generate.inc, line 107

Code

function devel_generate_add_terms(&$node) {
  $vocabs = taxonomy_get_vocabularies($node->type);

  // dsm($vocabs);
  foreach ($vocabs as $vocab) {
    $sql = "SELECT tid FROM {term_data} WHERE vid = %d ORDER BY RAND()";
    $result = db_query_range($sql, $vocab->vid, 0, 5);
    while ($row = db_fetch_object($result)) {
      if ($vocab->tags) {
        $node->taxonomy['tags'][] = $row->tid;
      }
      else {
        $node->taxonomy[$row->tid] = $row->tid;
      }
      if (!$vocab->multiple) {
        break;
      }
    }
  }
}