answers module

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));
//}
}
}
}

Drupal miracle

On two sites the new answers module is deployed. More or less on both sites the same set of modules is active. On one site if we want to view an answer an error is shown that the related question cannot be loaded by the EntityStructureWrapper: Unknown data property answers_related_question. On the other site this errors does not occur.
Subscribe to answers module