You are here

function single_page_site_page_build in Single Page Site 7

Implements hook_page_build().

File

./single_page_site.module, line 74

Code

function single_page_site_page_build(&$page) {
  global $language;
  $settings = variable_get('single_page_site_settings', array());
  if (!empty($settings)) {
    $path = drupal_get_path('module', 'single_page_site');
    $page['page_bottom']['single_page_site'] = array(
      '#attached' => array(),
    );
    $attached =& $page['page_bottom']['single_page_site']['#attached'];
    $options = array(
      'every_page' => TRUE,
    );

    // Add JS to create anchors.
    $attached['js'][$path . '/js/single-page-site-menu.js'] = $options;
    $settings_js = array(
      'className' => !empty($settings['class']) ? $settings['class'] : 'li',
      'menuClass' => $settings['menuclass'],
      'isFrontpage' => $settings['homepage'],
    );
    if (!$settings['homepage']) {
      $settings_js['singlePage']['urlAlias'] = drupal_get_path_alias('single-page-site', $language->language);
    }
    $attached['js'][] = array(
      'data' => array(
        'singlePage' => $settings_js,
      ),
      'type' => 'setting',
    );
  }
}