I have 3 content types. I have 3 vocabularies - one for each content type.
Recently I have created a script to save nodes programatically based on batch files clients send me. I am very happy with it, and it works fine.
However, I currently have to manually manage a separate file for a huge multidimensional array. Here is an excerpt from the file.
$query['baby_clothes']['category']['id'] = 1; $query['baby_clothes']['category']['id'] = 2; $query['baby_clothes']['category']['id'] = 3; $query['baby_clothes']['category']['id'] = 4; $query['feeding']['category']['id'] = 26; $query['feeding']['category']['id'] = 28;
The first dimension represents the content type and the others the id. There is one entry per unique taxonomy term id in the array. Basically I loop through the IDs; extract the content type from key ; save accordingly.
As the taxonomy grows and changes this becomes very inefficient to manage, and i would like to create these arrays dynamically, but I am having trouble understanding the database relationships to create this part of the code.
Basically it would work like this: "Get an array of content types. For each content type get the taxonomy IDs for the one vocabulary that is associated with the content type. Dynamically create the array."
Or, how about this? Would this be easier? "Get a list of taxonomy IDs. Get the content type with which this term is accociated. Now I have my content type and my id - save node accordingly."
I can see the node_type and taxonomy_vocabulary in the mysql database, but I am not sure how they relate to each other, or how to relate them so I get the desired result. I would prefer option two, but any direction is appreciated as well as are alternate suggestions. Pseudocode is fine. Thanks!