Site admins should be able to assign themes per given sub-domain. If a domain is not assigned it should the default assigned to the top-level domain.

CommentFileSizeAuthor
#2 domain_form.inc_theme.patch1.39 KBcanen
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

canen’s picture

After some quick browsing this is what I came up with so far. Keep in mind I do not understand the module that well as yet.

Assuming we have a settings form somewhere that assigns themes per sub-domain (look at sections module for an implementation idea) we could do something like this in the domain_conf module.

  $sub_domain_theme = db_result(db_query("SELECT theme from {domain_theme} where subdomain = '%s'", $subdomain));

  if ($sub_domain_theme) {
    // Taken from section module
    foreach(list_themes() as $key => $theme) {
      if ($theme->status == 1 && $theme->name == $sub_domain_theme) {
        global $custom_theme;
        $custom_theme = $sub_domain_theme;
      }
    }
  }

The query above should probable use the domain_conf table and the proper mysql_ and pg_ functions but the general idea is the same.

Am I on the right track?

canen’s picture

FileSize
1.39 KB

Quick patch attached. I'm not sure this works, in fact, I haven't even installed the module yet.

agentrickard’s picture

The approach is right. The trick will be making different theme configurations possible.

For example:

- Site A uses Garland with the default color scheme.
- Site B uses Garland with with 'Belgian Chocolate'.
- Site C uses Bluemarine.

This will be slightly more complex, and those settings should probably go into a {domain_theme} table. The settings would be loaded during hook_init().

After I get the core module in place, I'll devote some time to a domain_theme.module. But feel free to keep working in this direction.

canen’s picture

I know this is just the tip of the iceberg. I haven't even looked at user themes, etc.

agentrickard’s picture

The MySite module (which I also maintain) has some theme-switching features for users. You might take a look at how that is implemented.

The trick will be allowing user themes to override domain themes. Load order could be a factor here.

agentrickard’s picture

Version: » 5.x-1.0beta

Note that I committed to HEAD the start of some internal APIs.

The only one of note right now is hook_domanlinks(), which is simply used to present links on the admin screen.

Since some development is ongoing, you should patch / code against HEAD.

canen’s picture

I was actually going to request that :) Thanks. Have basic theme switching working. Very rudimentary.

agentrickard’s picture

Right. If you need other hooks, post them here.

One note: you can't fire module hooks during hook_init().

agentrickard’s picture

One second thought, post hook requests in this new issue.

agentrickard’s picture

FYI:

I'm actively developing the following:

- Domain Navigation == adds navigation block and menu options.
- Domain Content == allows affliate editors to perform batch editing processes.

As a result, I'm finding lots of places to reduce code overhead by creating simple functions. For example:

/**
 * Assigns the default settings to domain 0, the root domain.
 *
 * This value is used throughout the modules, so needed abstraction.
 */
function domain_default() {
  $default['domain_id'] = 0;
  $default['sitename'] = variable_get('domain_sitename', variable_get('sitename', 'Drupal'));
  $default['subdomain'] = variable_get('domain_root', '');
  $default['path'] = domain_get_path($domain);
  return $default;
}   

So the HEAD branch is definitely not stable. Expect major commits this week.

If you have other 'helper functions' that you need, post away.

And if you have some code for Domain Theme, I'd love to see it.

trailerparkopera’s picture

Priority: Normal » Minor

I've just installed Domain Access and it's a fantastic solution to what I am sure is a common problem. One request and an offer:

As you're developing the multi-theming function, one thought would be to work with the Taxonomy Theme developers to include HTTP_HOST into their list of things that gets evaluated when it decides to load up a theme. I find that I use Taxonomy Theme all the time, and would use it in addition to any theme switching function that you guys would work up.

Just a thought: it might make it easier for you to do this than to build your own solution.

I'm willing to help out as much as I can on this (testing, reporting, coding--my skills are limited).

agentrickard’s picture

That's a good head's up. I think we need to be sure that it works with Taxonomy Theme, but I prefer not to introduce an external dependency.

agentrickard’s picture

Priority: Minor » Normal
Status: Active » Closed (works as designed)

For now, I have committed a stripped down version of canen's code.

The current Domain Theme module only lets you select a default theme for each domain. Other settings must be entered through the normal theme administration screen.

Advanced theme settings functions may not need to be developed.

I'm going to mark this 'by design' to indicate that the issue is still active, but a decision has been made. That decision may be revisited if people contribute more code.

@canen -- I loved your first pass at the module, but it may have been too complex for most users.

canen’s picture

No problem. Whatever works. I'll have a look at it.