I am using domain access and Theme and display suite. There I define in the theme several ds-layouts and running into a problem.
On my default domain I have theme A as default defined.
on domain 2 I have theme A defined (same as default domain)
on domain 3 I have theme B defined
When in domain 3 the directory in the theme B for extra ds_layouts is not read although it is the standard theme for that domain. I have to place extra ds_layout files into the default domain theme otherwise they are not recognized.

This makes things a bit messy since I eventually want to have another default theme in the default domain. However as soon I do so none of my ds_layouts (css and tpl files) are anymore available in display suite. Off course I like to keep the extra layouts for DS seperated per domain, but that does not seem to be possible.
It looks like the default theme for a certain domain is not being recognized by Display suite.
Not sure if this a problem in DS or in domains.

Some help would be appreciated.

CommentFileSizeAuthor
#8 1719578-ds-theme-active.patch1.05 KBagentrickard
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

agentrickard’s picture

Category: bug » support

No idea. I don't use DS.

Anyone else?

agentrickard’s picture

You _might_ try changing the execution order of Domain Theme -- there is a setting for that on the Domain settings page. If Domain Theme is firing after DS, it may be too late.

erald’s picture

That does not do anything.
strange thing is that the tpl has to be in Theme B when on domain 3 but the css has to be in Theme A.

That is the only way I could get it to work.

agentrickard’s picture

Sounds like a caching issue either in Drupal core or DS.

agentrickard’s picture

I'm looking at _ds_layouts_scan_theme() inside ds.registry.inc.

From what I can see, it will scan directories based on the current theme, but I can't track down where it stores that information (and for how long.)

erald’s picture

Have some more info which might help;
When creating a layout in Theme B for site 3 it is not recognized when trying to select the layout in manage display.
When looking at the code in _ds_ds_layout_info() it scans the variable 'theme_default' which is the default site (site 1) theme A. So it never finds it.
Putting the file .inc it in the default theme (Theme A) it will be in the drop down list.
The tpl file should be in theme B folder otherwise it is not working.
The css file has to be with the inc file in theme A.

I tested this and clearing every time the cache. It looks like DS is searching for the tpl file for the active theme where it looks for the inc and css file for the default theme.

agentrickard’s picture

Project: Domain » Display Suite
Version: 7.x-3.4 » 7.x-2.x-dev
Component: - Domain Theme » Code
Category: support » bug

If it's looking for theme_default, then I suspect the problem is that domain_theme_custom_theme() needs to set that value. That's not how hook_custom_theme() works, however.

This is potentially a bug in DS, since it should be smart enough to recognize theme switching.

DS is missing the following logic from drupal_theme_initialize().

  // Allow modules to override the theme. Validation has already been performed
  // inside menu_get_custom_theme(), so we do not need to check it again here.
  $custom_theme = menu_get_custom_theme();
  $theme = !empty($custom_theme) ? $custom_theme : $theme;

So replace this code in _ds_ds_layout_info():

  // Get layouts defined in the default theme and base theme (if applicable).
  $theme = variable_get('theme_default');
  $themes = list_themes();

With:

 $themes = list_themes();

  // Only select the user selected theme if it is available in the
  // list of themes that can be accessed.
  $theme = !empty($user->theme) && drupal_theme_access($user->theme) ? $user->theme : variable_get('theme_default', 'bartik');

  // Allow modules to override the theme. Validation has already been performed
  // inside menu_get_custom_theme(), so we do not need to check it again here.
  $custom_theme = menu_get_custom_theme();
  $theme = !empty($custom_theme) ? $custom_theme : $theme;
agentrickard’s picture

Status: Active » Needs review
FileSize
1.05 KB

Here's a proper patch.

agentrickard’s picture

Title: Display suite theming. » DS ignores hook_custom_theme()

Better title. Perhaps DS does this deliberately. If so, that should be documented.

erald’s picture

Great this works like a charm.
Just had to transfer a few layouts to the correct theme and clear the caches.:)
Thank you so much

agentrickard’s picture

Status: Needs review » Reviewed & tested by the community
erald’s picture

Well was a bit too quick. It works on the site however when I am using an administrative theme and this returns the admin theme where there is no ds-layout. So it does not recognize my custom layouts anymore. When I disable the admin theme it works but my theme is not really suitable for editing the displays.

This might be a problem in domains access not sure since have no exact knowledge on the internal working on how to select the theme.

To solve it I added to your patch some code to select the domain default theme;

  // Only select the user selected theme if it is available in the
  // list of themes that can be accessed.
  $theme = !empty($user->theme) && drupal_theme_access($user->theme) ? $user->theme : variable_get('theme_default', 'bartik');

  // Allow modules to override the theme. Validation has already been performed
  // inside menu_get_custom_theme(), so we do not need to check it again here.
  $custom_theme = menu_get_custom_theme();
  $theme = !empty($custom_theme) ? $custom_theme : $theme;
	// override domain
  $_domain = domain_get_domain();
  $domain_theme = domain_theme_lookup($_domain['domain_id']);
  if ($theme != -1) {
	$theme = $domain_theme['theme'];
  }

Probably not the way to go but it works for me now. Can edit the layouts which are defined in the domain theme and it displays it correctly.
>> edit this does not work as expected. something screwed up since the admin pages are now in the theme at once. will be back on this.
>>> edit ok seems my browser and some caches where the problem things got wrong. reset everything logged out and logged in again clear caches again and now it is working. sorry for the confusion

agentrickard’s picture

The admin theme is provided by a core hook (system_custom_theme) and is not related to Domain Theme. It is actually working as expected in this case.

Why is loading the admin theme a problem? The admin theme should provide its own DS layouts.

erald’s picture

I use the admin theme to edit the display layout and in that case the layout is not available for the domain theme. The patch you gave is working ok as long you are editing in the domain theme itself however when trying to do so in the admin theme the ds-layout is not seen anymore from the domain theme. The ds-layout has to be in the admin theme in that case.

Hope this is a bit clear.

swentel’s picture

Issue tags: +RC blocker

tagging for the sprint this wednesday so I don't forget to commit this, thanks for the patch agentrickard !

swentel’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -RC blocker

committed and pushed, thanks!

swentel’s picture

Status: Fixed » Needs work

Hrm, I had to revert this as it broke every functionality on our projects. We lost all the layouts defined in our frontend theme. Not sure exactly how to go forward with this.

agentrickard’s picture

How did it break the core functionality? (That is, in what way?)

swentel’s picture

Well, we have some layouts defined in our theme, which is set as the default theme, no others are used in this site. We don't use domain access or anything, but with the patch, on the administration pages (over at admin -> structure -> content types -> manage display), the $theme was now set to seven and it did not find those layouts anymore. The code in the ds.registry.inc is used while doing administration of the display, not during rendering.

agentrickard’s picture

That sounds consistent with what the OP said in #14.

erald’s picture

Maybe this problem with a solution is the same or anyway related..

Taxoman’s picture

(The link in #21 points to #1766022: Theme not kept in a domain (Domain Access module issue), which is marked as a duplicate of this issue.)

flyke’s picture

Issue summary: View changes

I just had the same issue:
Working on a project with one drupal installation using the domain module and 2 domains.
Each domain had its own theme.
In each theme, there were ds_layouts that were only needed on the specific domain that uses the theme.

On domain A it woul sometimes only see the ds_layouts from the theme of domain B et vice versa. This seems to be depending on what theme is set as the default theme in admin/appearance. Although in domain settings, the correct theme for that domain have been set).

I tested patch #8 and after some cache clearing, this seemed to have worked.
However the next day, I got an error message again on domain A that is was basically looking for the needed ds_layouts in the theme for domain B.
When I cleared cache, it was working again. This, of course, is not viable when the website would go live that we would have to clear caches once in a while.

The correct solution to this problem was using a base theme. This solved all the issues. For anyone having same problems, here is how to make the base theme:
- in sites/all/themes: create a folder 'basetheme'
- in sites/all/themes/basetheme: create a basetheme.info file:

name = My awesome base theme
description = Base theme for solving domain ds_layouts issues
core = 7.x
engine = phptemplate

- in sites/all/themes/basetheme: create a blank template.php file
- in sites/all/themes/basetheme: create a folder ds_layouts and in there put all ds_layouts from both theme A and theme B
- delete the folders ds_layouts from theme A and theme B, so they are only in the basetheme
- modify the .info file of theme A and theme B to use the base theme by adding this line under description:

base theme = basetheme

- in admin/appearance: set basetheme as default theme
- clear caches

Things should be working now. If it's not working, then you may have tried the patch here in #8. That causes this solution to not work. Undo this patch and things should be fine.

In hindsight, the thought 'i only need these ds_layouts for this domain so using a base theme is a waste of time, they should only be in my specific theme folder' was the problem. It is actually really better to have all the ds_layouts in one place and being able to use them on both domains.