I would like to allow my users to create a story with a pre-assigned taxonomy term. Basically eliminating the need for them to choose the term themselves (which they may forget to do).

I know that arguments can be used in links to link to a node which is already tagged with a particular term. What I envision is the reverse: configure the node/add link to assign the term upon node creation.

Alternatively, I could just create a new content type specifically for this type of story, but I would prefer not to do that.

Does anyone know if this is possible?

Comments

kuldip zala’s picture

Hello Michael

Write custom module and use hook_form_alter
Using hook_form_alter assign your fix taxonomy term as default value for that.

Thanks,
Kuldip Zala

gogowitsch’s picture

The way I just did it:

  1. add a column named nid of type int(10) to the table term_data. You can do so by using SQL or phpMyAdmin (choose table from the list in the left, make sure you are in the 'structure' tab and click the tiny 'OK' button just below the table).
  2. Fill in node ids (nid) for each term. If you are using pathauto, you can see a node's nid by noting the number in the url of the edit page of the node.
  3. Open your template's page.tpl.php and insert the following:
    if (arg(1)=='term' && is_numeric(arg(2))) {
      $tid = arg(2);
      $query = 'SELECT nid FROM {term_data} WHERE tid = ' . $tid;
      $res = db_query($query);
      if ($item = db_fetch_object($res)) {
        if ($item->nid > 0) {
          drupal_goto('node/' . $item->nid);
        }
      }
    }