function hosting_alias_node_view

7.x-3.x hosting_alias.module hosting_alias_node_view($node, $view_mode, $langcode)

Implements hook_node_view().

File

alias/hosting_alias.module, line 400
Allow sites to have domain aliases that they can be accessed with.

Code

function hosting_alias_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'site') {

    if (count($node->aliases)) {
      foreach ($node->aliases as $link) {
        $links[] = l($link, "http://$link");
      }
      $node->content['info']['aliases'] = array(
        '#type' => 'item',
        '#title' => t('Domain aliases'),
        '#markup' => implode(', ', $links),
        '#weight' => 10,
      );
      $redirection = db_query("SELECT redirection FROM {hosting_site_alias} WHERE vid = :vid", array(':vid' => $node->vid))->fetchAssoc();
      $node->content['info']['redirection'] = array(
        '#type' => 'item',
        '#title' => t('Redirection'),
        '#markup' => $redirection['redirection'] ? t('Yes') : t('No'),
        '#weight' => 12,
      );
    }

    // List the automatic aliasses.
    if (count($node->aliases_automatic)) {
      $links = array();
      foreach ($node->aliases_automatic as $link) {
        $links[] = l($link, "http://$link");
      }
      $node->content['info']['aliases_automatic'] = array(
        '#type' => 'item',
        '#title' => t('Auto aliases'),
        '#markup' => implode(', ', $links),
        '#weight' => 11,
      );
    }
  }
}