You are here

function domain_nav_render in Domain Access 7.3

Same name and namespace in other branches
  1. 5 domain_nav/domain_nav.module \domain_nav_render()
  2. 6.2 domain_nav/domain_nav.module \domain_nav_render()
  3. 7.2 domain_nav/domain_nav.module \domain_nav_render()

Renders output for the block.

This function is extracted for use in your themes. Just call: domain_nav_render($paths = 0, $style = 'default');

Parameters

$paths: A boolean flag indicating how to write links to other domains: 0 == link to home page of selected domain 1 == link to current url on selected domain

$style: Indicates which theme function to invoke. Default options are: 'default' == theme_domain_nav_default() 'menus' == theme_domain_nav_menus() 'ul' == theme_domain_nav_ul()

Return value

A themed HTML object for navigation.

1 call to domain_nav_render()
domain_nav_block_view in domain_nav/domain_nav.module
Implements hook_block_view().

File

domain_nav/domain_nav.module, line 190
Navigation block and menu options for Domain Access

Code

function domain_nav_render($paths = NULL, $style = NULL) {
  $_domain = domain_get_domain();
  if (!user_access('access domain navigation')) {
    return;
  }

  // Get the options and set the variables.
  if (empty($paths)) {
    $paths = variable_get('domain_nav_block', 0);
  }
  if (empty($style)) {
    $style = variable_get('domain_nav_theme', 'default');
  }
  $options = array();
  $domains = domain_domains();

  // Select which path calculation to use.
  $paths == 0 ? $func = 'domain_get_path' : ($func = 'domain_get_uri');
  foreach ($domains as $key => $value) {
    $allow = TRUE;

    // If the domain is not valid, we disable it by default.
    if (!$value['valid']) {
      if (user_access('access inactive domains')) {
        $value['sitename'] .= ' *';
      }
      else {
        $allow = FALSE;
      }
    }
    if ($allow) {
      if ($_domain['subdomain'] == $value['subdomain']) {
        $value['active'] = TRUE;
      }
      $path = $func($value);
      $value['path'] = $path;

      // Allow other modules to add elements to the array.
      $extra = array();
      $extra = module_invoke_all('domain_nav', $value);
      $value = array_merge($value, $extra);
      $options[$value['domain_id']] = $value;
    }
  }
  $theme = 'domain_nav_' . $style;
  drupal_alter('domain_nav_options', $options);
  $content = theme($theme, array(
    'options' => $options,
  ));
  return $content;
}