0

I use drupal 7. I created a content type with these fields:

  1. one field to upload a file to private folder
  2. a taxonomy field (for that file)

my problem: i can save one file with one taxonomy! but how should i get these data again!(is there any API here) I want to know which taxonomy was saved for a certain file(i need to check it inside my custom module). i raised similar question here: so by following code i can get corresponding field:

$nids = db_query("SELECT nid FROM node WHERE title LIKE :title", array(':title' => '%'.$title.'%'))->fetchCol();

$nodes = node_load_multiple($nids);

foreach($nodes as $node) {

// using field_get_items here automatically loads the field in the correct language
$field_items = field_get_items('node', $node, 'field_subtitle');
$subtitle = $field_items[0]['safe_value'];
}

but it seems it dose not work taxonomy attached field.

why do i have this question: i sell some digital files and now i am developing a module for selling my files. i want to sell them this way: each file has a certain taxonomy. when my user buys that file he or she gets that taxonomy(and i will keep it in one table). once he clicks on download link i have to check whether that user has that taxonomy already or not! if he has i will let him to download it.

6
  • 2
    Welcome to Drupal Answers! For which Drupal version are you interested to? There are quite important differences between Drupal 6 and Drupal 7. Then, if you were interested in Drupal 7, is there any reason to query the database instead of using the correct API?
    – apaderno
    Commented Apr 2, 2014 at 12:05
  • I edited the question. plz help me if there is any API for loading relevant fields
    – PersianMan
    Commented Apr 2, 2014 at 19:26
  • So it the taxonomy field attached to the users profile as well as your content type?
    – Felix Eve
    Commented Apr 3, 2014 at 7:55
  • yes. i attach taxonomy to content type but for user just enter them in a separate table. my problem is there with taxonomies and content type. I dont know how to get them
    – PersianMan
    Commented Apr 3, 2014 at 8:01
  • Why not also attach the taxonomy to the users profile?
    – Felix Eve
    Commented Apr 3, 2014 at 14:43

1 Answer 1

0

You can see the relationship by viewing or editing the node.

If you mean where is this data stored in the DB then if you created a field called file_type then the tid of the associated taxonomy term would be found in the field_data_field_file_type table.

The names of the taxonomy terms are stored in the taxonomy_term_data table.

2
  • It all depends from which Drupal version the OP is using. Then, I don't see why the user would be querying the database directly, on Drupal 7.
    – apaderno
    Commented Apr 2, 2014 at 12:07
  • i edited my post and explain why i need to go to my database directly! help me if there is any API in this regard
    – PersianMan
    Commented Apr 2, 2014 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.