function faq_view_answer in Frequently Asked Questions 7
Same name and namespace in other branches
- 5.2 faq.module \faq_view_answer()
- 6 faq.module \faq_view_answer()
- 7.2 faq.module \faq_view_answer()
Helper function to setup the faq answer.
Parameters
array &$data: Array reference to store display data in.
object $node: The node object.
array $back_to_top: An array containing the "back to top" link.
bool $teaser: Whether or not to use teasers.
array $links: Whether or not to show node links.
7 calls to faq_view_answer()
- template_preprocess_faq_category_hide_answer in includes/
faq.hide_answer.inc - Create categorized FAQ page if set to show answer when question is clicked.
- template_preprocess_faq_category_questions_inline in includes/
faq.questions_inline.inc - Create categorized FAQ page if set to show/hide the questions inline.
- template_preprocess_faq_category_questions_top in includes/
faq.questions_top.inc - Create categorized questions for FAQ page if set to show questions on top.
- template_preprocess_faq_category_questions_top_answers in includes/
faq.questions_top.inc - Create categorized answers for FAQ page if set to show the questions on top.
- template_preprocess_faq_hide_answer in includes/
faq.hide_answer.inc - Create FAQ page if set to show/hide answer when question is clicked.
File
- ./
faq.module, line 1259 - 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(&$data, $node, $back_to_top, $teaser, $links) {
$view_mode = $teaser ? 'teaser' : 'full';
$langcode = $GLOBALS['language_content']->language;
// Build the faq node content and invoke other modules' links, etc, functions.
$node = (object) $node;
node_build_content($node, $view_mode, $langcode);
// Add "edit answer" link if they have the correct permissions.
if (node_access('update', $node)) {
$node->content['links']['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->content['links']['node']['#links']['faq_back_to_top'] = $back_to_top;
}
$build = $node->content;
// We don't need duplicate rendering info in node->content.
unset($node->content);
$build += array(
'#theme' => 'node',
'#node' => $node,
'#view_mode' => $view_mode,
'#language' => $langcode,
);
// Add contextual links for this node.
if (!empty($node->nid) && !($view_mode == 'full' && node_is_page($node))) {
$build['#contextual_links']['node'] = array(
'node',
array(
$node->nid,
),
);
}
// Allow modules to modify the structured node.
$type = 'node';
drupal_alter(array(
'node_view',
'entity_view',
), $build, $type);
$node_links = $links ? $build['links']['node']['#links'] : (!empty($back_to_top) ? array(
$build['links']['node']['#links']['faq_back_to_top'],
) : NULL);
unset($build['links']);
// We don't want node title displayed.
unset($build['#theme']);
$content = drupal_render($build);
$data['body'] = $content;
$data['links'] = !empty($node_links) ? theme('links', array(
'links' => $node_links,
'attributes' => array(
'class' => 'links inline',
),
)) : '';
}