0

my D7 site will be accessible from 4 different subdomains: - a.site.com - b.site.com - c.site.com - www.site.com (or just site.com)

I already enabled a domain cookie for .site.com and the login works across all subdomains.

Now I want to be able to show a different logo logo based on the subdomain and I also want to be able to switch the main menu links.

I tried the context module but didn't find a way to detect the subdomain.

I don't want to use the domain access module. I was thinking about modifying the theme to switch the logos. Can I do the same for the menu links?

Does anyone have a better idea?

  • Do you use different themes for each site or one theme for all subdomains ? – Refineo Sep 18 '11 at 20:59
  • they use the same theme – uwe Sep 19 '11 at 4:05
3

I am unaware of any contrib modules that do this (well, other than Domain Access), but it would be pretty trivial to write a little custom code to accomplish it.

Essentially, you would add something to your theme preprocess to detect the domain and tack on body classes. How to do this depends on whether you are using Drupal 6 or Drupal 7. Either method, though, would use $_SERVER["HTTP_HOST"] to detect the theme.

Then, in your CSS you would preface your logo rules with body.whatever to choose the correct one.

The menu thing is a little trickier. You would use essentially the same logic, but set a variable containing the proper menu and print this out in your theme. To be honest, though, I really would use Domain Access for this if you are using Panels. The domain shows up as a panel selection rule, so you can do all of this from the UI.

  • thanks. I looked into Domain Access and it worked great but it seemed to be too much for what I try to accomplish. Also, I don't want to use Panels yet, trying to keep things as simple as possible. Thanks again – uwe Sep 19 '11 at 17:56
  • 1
    Glad I could help. Personally, I always use Panels from the get-go, as it is easier to rework what a panel does than to redo a site to use panels. A lot of modules that you may want in the future (Domain Access, Mobile Tools, etc) also integrate nicely into Panels. – mpdonadio Sep 19 '11 at 18:29
2

You need this: https://drupal.org/project/domain

& https://drupal.org/project/domain_menu_access

Using domain module you can manage various settings like theme, block for specific domain.

Using domain menu access you can restrict specific menu link to appear in specific domain under menu configuration settings.

0

I tried the context module but didn't find a way to detect the subdomain.

You need to use the Context Domain module. I'm not sure about the logos, but maybe you can use Context Reaction Menus for handling the main menu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.