You are here

function hosting_subdirs_node_presave in Hosting 7.4

Same name and namespace in other branches
  1. 7.3 subdirs/hosting_subdirs.module \hosting_subdirs_node_presave()

Implements hook_node_presave().

Handle subdir-specific configuration for a new site.

File

subdirs/hosting_subdirs.module, line 104
Allow sites to be installed in subdirectories.

Code

function hosting_subdirs_node_presave($node) {

  // Note that we set this module's weight to ensure that it runs before
  // hosting_site. This is specifically so that $node->title here is still the
  // subdir domain.
  // @see: hosting_subdirs_install().
  if ($node->type == 'site' && hosting_subdirs_is_a_subdir($node->title)) {

    // Add an alias and redirection to the subdir URL.
    $node->aliases[] = $node->redirection = $node->title;
  }
  elseif (isset($node->subdir_aliases) && isset($node->subdir_redirection)) {
    $node->aliases = $node->subdir_aliases;
    $node->redirection = $node->subdir_redirection;
  }
}