metadata wrapper

First trial was to analyse the function answers_init, where
drupal_goto('node/' . $node->answers_related_question->value()->nid, array('fragment' => 'node-' . $node->nid->value(), 'alias' => TRUE));
is called to change the URL for viewing the answer together with the question.

Instead of a simple node structure the whole entity is passed via arg(1). And thus I do not need the entity_metadata_wrapper to extract data.

function answers_init() {
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
$node = node_load(arg(1));
if ($node != '' && $node->type == 'answers_answer') {
if(!isset($node->answers_related_question))
$node = entity_metadata_wrapper('node', $node);
//if ($node->type->value() == 'answers_answer') {
drupal_goto('node/' . $node->answers_related_question['und'][0]['target_id'], array('fragment' => 'node-' . $node->nid, 'alias' => TRUE));
//drupal_goto('node/' . $node->answers_related_question->value()->nid, array('fragment' => 'node-' . $node->nid->value(), 'alias' => TRUE));
//}
}
}
}

Subscribe to metadata wrapper