Hi all,

I would like to do the following. I'm not sure if its possible with this module.

My client has a Drupal site. Say www.example.com.

They would like uk.example.com to have the UK logo at the top of the page and us.example.com to have the USA logo at the top etc... For the rest they'd like the site to be exactly the same. Would this be possible with the subdomain module?

Thanks!!

Comments

colemanw’s picture

I assume you're using version 1.x. In that case, no problemo.
The cleanest way would be to drop this code into your hook_preprocess_page function in your theme's template.php file:

	// get current subdomain (works even for node/xxx/edit!)
	$path = explode('/', $_GET['q'] );
	if ( $path[0] == 'node' && is_numeric($path[1])  )
		$alias = drupal_get_path_alias( $path[0].'/'.$path[1] );
	else
		$alias = drupal_get_path_alias( $_GET['q'] );
	$aliasarray = explode('/', $alias);

	// add subdomain to body classes
	if (substr($aliasarray[0], 0, 1) == '~') {
		$domain = substr($aliasarray[0], 1);
	}
	else {
		$domain = 'home';
	}
	$vars['body_classes_array'][] = 'site-'.$domain;
  $vars['body_classes'] = implode (' ', $vars['body_classes_array']);

Now you've got your subdomain as a body class, and you can theme the logo, or anything else your heart desires, with css.

Of course, you could also just override the $logo variable here and be done with it, by adding this line to the end:

$vars['logo'] = '/sites/default/files/logos/'.$domain.'-logo.png';

Then just make a folder of logos in that directory with the correct names (in this example it would be /sites/default/files/logos/uk-logo.png)

Good luck :)

ratinakage’s picture

Thanks!

colemanw’s picture

You're welcome.
For the second piece, about everything else being exactly the same, if you are refering to content, you can do this simply by giving one node multiple aliases.
So if you make node/1 your front page, you could also give it the aliases ~uk and ~au and then it will be the front page of uk.example.com and au.example.com as well.
Good luck.