I'm creating a module that lists tagged articles, special articles, and specific comments.
For the list, I'm getting all the nodes that are tagged and displaying the titles like this:
// find nodes associated with term X
$terms = taxonomy_get_term_by_name('X');
$keys = array_keys($terms);
$nodes = array();
foreach($keys as $key) {
$nodes = array_merge(taxonomy_select_nodes($key),$nodes);
}
// get all nodes associated with term X
$options = array();
$query = db_select('node', 'n', $options);
$query->fields('n');
$query->condition('nid', $nodes, 'IN');
$query->orderBy('title', 'asc');
$output = $query->execute();
This works great!
I would also like to be able to get the body associated with the nodes (from the table field_data_body). I can see how it is associated in the database, but which api method(s) would get this information?
On the flip side, I would also like to be able to create this content from a data file.
How would I create an article, for example, that would have a title, some body, and be tagged?
So my pseudo-code would be something like this:
nid = create node with title='abc 123' and type='article';
create a body for node=nid with body_value='Lorem ipsum dolor';
tag node with term='X';