You are here

function faq_view_answer in Frequently Asked Questions 5.2

Same name and namespace in other branches
  1. 6 faq.module \faq_view_answer()
  2. 7.2 faq.module \faq_view_answer()
  3. 7 faq.module \faq_view_answer()

Helper function to setup the faq answer.

Parameters

$node: The node object.

$back_to_top: An array containing the "back to top" link.

$teaser: Whether or not to use teasers.

$links: Whether or not to show node links.

$answer_label: Answer label, if set.

$class: An additional class name to assign the div containing the answer.

Return value

HTML formatted string containing the answer.

7 calls to faq_view_answer()
theme_faq_category_hide_answer in includes/faq.hide_answer.inc
Create the code of the FAQ page if set to show/hide the category-sorted answers when the question is clicked.
theme_faq_category_questions_inline in includes/faq.questions_inline.inc
Create the code of the FAQ page if set to show/hide the category-sorted questions inline.
theme_faq_category_questions_top in includes/faq.questions_top.inc
Create the layout of the FAQ page if set to show the questions on top, all sorted by categories.
theme_faq_category_questions_top_answers in includes/faq.questions_top.inc
Create the layout of the answers if set to show the questions on top, all sorted by categories.
theme_faq_hide_answer in includes/faq.hide_answer.inc
Create the structure of the FAQ page if set to show/hide the answers when the question is clicked.

... See full list

File

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

Code

function faq_view_answer($node, $back_to_top, $teaser, $links, $answer_label = '', $class = NULL) {

  // Build the faq node content and invoke other modules' links, etc, functions.
  $node = (object) $node;
  $node = node_build_content($node, $teaser, 0);
  if ($links) {
    $node->links = module_invoke_all('link', 'node', $node, $teaser);
    foreach (module_implements('link_alter') as $module) {
      $function = $module . '_link_alter';
      $function($node, $node->links);
    }
  }

  // Add "edit answer" link if they have the correct permissions.
  if (node_access('update', $node)) {
    $node->links['faq_edit_link'] = array(
      'title' => t('Edit answer'),
      'href' => "node/{$node->nid}/edit",
      'query' => drupal_get_destination(),
      'attributes' => array(
        'title' => t('Edit answer'),
      ),
    );
  }

  // Add "back to top" link.
  if (!empty($back_to_top)) {
    $node->links['faq_back_to_top'] = $back_to_top;
  }
  $content = drupal_render($node->content);
  node_invoke_nodeapi($node, 'alter', $teaser, 0);

  // Unset unused $node text so that a bad theme can not open a security hole.
  $node->body = $content;
  $node->teaser = NULL;
  return theme('faq_format_answer', $node, check_plain($answer_label), $class);
}