public static function FaqViewer::initBackToTop in Frequently Asked Questions 8
Helper function to setup the "back to top" link.
Parameters
string $path: The path/url where the "back to top" link should bring the user too. This could be the 'faq-page' page or one of the categorized faq pages, e.g 'faq-page/123' where 123 is the tid.
Return value
An array containing the "back to top" link.
2 calls to FaqViewer::initBackToTop()
- FaqViewer::viewAnswer in src/
FaqViewer.php - Helper function to setup the faq answer.
- template_preprocess_faq_questions_inline in includes/
faq.questions_inline.inc - Create the FAQ page if set to show the questions inline.
File
- src/
FaqViewer.php, line 116
Class
- FaqViewer
- Controlls the display of questions and answers.
Namespace
Drupal\faqCode
public static function initBackToTop() {
$faq_settings = \Drupal::config('faq.settings');
$back_to_top = '';
$back_to_top_text = trim($faq_settings
->get('back_to_top'));
if (!empty($back_to_top_text)) {
$options = array(
'attributes' => array(
'title' => t('Go back to the top of the page.'),
),
'html' => TRUE,
'fragment' => 'top',
);
$back_to_top = Link::fromTextAndUrl($back_to_top_text, Url::fromUserInput('#', $options))
->toString();
}
return $back_to_top;
}