single_page_site_next_page.module in Single Page Site 7
File
modules/single_page_site_next_page/single_page_site_next_page.module
View source
<?php
function single_page_site_next_page_single_page_site_output_alter(&$output, $current_item) {
$menu_items = single_page_site_next_page_get_single_page_items();
$count_menu_items = count($menu_items);
if ($current_item < $count_menu_items) {
$menu_item = $menu_items[$current_item];
if (empty($menu_item['#localized_options']['attributes']['class']) || !empty($menu_item['#localized_options']['attributes']['class']) && !in_array('hide', $menu_item['#localized_options']['attributes']['class'])) {
$next_link = $menu_item['#href'];
$anchor = _single_page_site_generate_anchor(drupal_get_path_alias($next_link));
$output .= l(_single_page_site_get_title($menu_item), '', array(
'fragment' => $anchor,
'external' => TRUE,
'attributes' => array(
'class' => array(
'to-next-page',
),
),
));
}
}
}
function single_page_site_next_page_get_single_page_items() {
$settings = variable_get('single_page_site_settings', array());
$items = array();
$menu_name = $settings['menu'];
$tree = menu_tree($menu_name);
foreach ($tree as $key => $item) {
$render_menu_item = FALSE;
if (is_numeric($key)) {
if ($item['#href'] != '<front>') {
if (empty($settings['class'])) {
$render_menu_item = TRUE;
}
elseif (!empty($item['#title']) && !empty($item['#localized_options']['attributes']['class']) && in_array($settings['class'], $item['#localized_options']['attributes']['class'])) {
$render_menu_item = TRUE;
}
}
}
if ($render_menu_item) {
$items[] = $item;
}
}
return $items;
}