You are here

function new_faq_load in Frequently Asked Questions 7.2

Implements hook_load().

Initialises $node->question using the value in the 'faq_questions' table.

Parameters

$nodes: The node object.

File

./faq.module, line 345
The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.

Code

function new_faq_load($nodes) {
  foreach ($nodes as $nid => &$node) {
    $result = db_query('SELECT question, detailed_question FROM {faq_questions} WHERE nid = :nid AND vid = :vid', array(
      ':nid' => $node->nid,
      ':vid' => $node->vid,
    ))
      ->fetchObject();
    if ($result && !drupal_match_path($_GET['q'], 'node/' . $node->nid . '/edit')) {
      $question_length = variable_get('faq_question_length', 'short');
      if ($question_length == 'long' && !empty($result->detailed_question)) {
        $result->title = $result->detailed_question;
      }
      else {
        $result->title = $result->question;
      }
    }
    foreach ($result as $property => &$value) {
      $node->{$property} = $value;
    }
  }
}