1 book.theme.inc | template_preprocess_book_navigation(&$variables) |
Processes variables for book-navigation.tpl.php.
Parameters
$variables: An associative array containing the following key:
- book_link
See also
File
- core/
modules/ book/ book.theme.inc, line 38 - Theme functions for the Book module.
Code
function template_preprocess_book_navigation(&$variables) {
$book_link = $variables['book_link'];
// Provide extra variables for themers. Not needed by default.
$variables['book_id'] = $book_link['bid'];
$variables['book_title'] = check_plain($book_link['link_title']);
$variables['book_url'] = 'node/' . $book_link['bid'];
$variables['current_depth'] = $book_link['depth'];
$variables['tree'] = '';
if ($book_link['mlid']) {
$navigation = _book_get_cached_navigation($book_link);
$navigation_options = config_get('book.settings', 'book_navigation_options');
if (in_array('tree', $navigation_options, TRUE)) {
$variables['tree'] = $navigation['tree'];
}
if (in_array('pager', $navigation_options, TRUE) && $navigation['prev']) {
$prev_href = url($navigation['prev']['href']);
backdrop_add_html_head_link(array('rel' => 'prev', 'href' => $prev_href));
$variables['prev_url'] = $prev_href;
$variables['prev_title'] = check_plain($navigation['prev']['title']);
}
if (in_array('pager', $navigation_options, TRUE) && $book_link['plid'] && $navigation['parent']) {
$parent_href = url($navigation['parent']['href']);
backdrop_add_html_head_link(array('rel' => 'up', 'href' => $parent_href));
$variables['parent_url'] = $parent_href;
$variables['parent_title'] = check_plain($navigation['parent']['title']);
}
if (in_array('pager', $navigation_options, TRUE) && $navigation['next']) {
$next_href = url($navigation['next']['href']);
backdrop_add_html_head_link(array('rel' => 'next', 'href' => $next_href));
$variables['next_url'] = $next_href;
$variables['next_title'] = check_plain($navigation['next']['title']);
}
}
$variables['has_links'] = FALSE;
// Link variables to filter for values and set state of the flag variable.
$links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title');
foreach ($links as $link) {
if (isset($variables[$link])) {
// Flag when there is a value.
$variables['has_links'] = TRUE;
}
else {
// Set empty to prevent notices.
$variables[$link] = '';
}
}
}