I have been tasked to divide up quite a large website (www.aspergillus.org.uk currently using AT 7.x-3.1 in drupal 7) into distinct sections so that someone seeing articles will see a different logo/colour/text/layout compared with someone browsing the conferences section for example.
They would like 10-20 distinct sections.

I have looked at ThemeKey module but that seemed to want an entire new theme for each section which I imagine would be great but result in 10-20 slightly different versions of the whole AT theme which would be good but quite a heavyweight solution in terms of server space and much of the code would be redundant. That seems a little unnecessary given the small differences we envisage between sections.

I have looked at Delta module (with Context module) but that does not seem to work with AT and does not seem to be maintained.

I have looked at Sections module but there is no version for Drupal 7.

I have looked at Context module but again that looks like it works from mutiple copies of entire themes.

Is there a lighter weighted option for creating sections in an AT website??

Comments

GAtherton created an issue.

jwkovell’s picture

Depending on how maintainable you need it to be, you could possibly get what you want by adding a single preprocess HTML hook to theme's THEME_NAME.theme (D8) or template.php (D7) file.

function [THEME_NAME_HERE]_preprocess_html(&$variables) {

  $request_url = $_SERVER['REQUEST_URI'];
  $site_section = 'default';

  if (strpos($request_url, '/about/') !== false) {
    $site_section = 'about';
  }
  elseif (strpos($request_url, '/contact/') !== false) {
    $site_section = 'contact';
  }
  elseif (strpos($request_url, '/store/') !== false) {
    $site_section = 'store';
  }

  $variables['site_section'] = $site_section;

}

Then use that variable in your page/html template to switch out parts of the layout or add it as a CSS class on a top-level element (body?) to recolor any children elements as needed.

A module that lets you manage the sections would be better, but if the sections are set in stone, this might work.

GAtherton’s picture

Thank you for your suggestions jKovell - apologies for the delay in getting back to you I was lucky enough to get a few days vacation last week.

We do need this to be maintainable so adding in custom code may cause us problems in the future - a module would be better, I guess I am asking if anyone has any experience of what I am trying to do - surely there are many websites out there which are themed according to section without having to upload an entire theme for each subsection?

jwkovell’s picture

Sorry, I haven't found anything like that in an existing contrib module yet - and nothing directly related to AdaptiveTheme.

Just spitballing ideas: In Drupal 7, it was possible to create an AdaptiveTheme sub-subtheme. AT sub-subthemes only contain the differences with the theme they're based on. If the only problems with ThemeKey are server space and the pain of managing redundant code, sub-subthemes could solve that problem. I haven't had to do that in Drupal 8 yet, though, so I'm just assuming that's still a feature.

Alternatively, the code mentioned above could be turned into a maintainable module using configuration entities, if a custom module is a path you want to explore.

If you're still looking for a contrib solution, you may need to cast a wider net outside the AT issue queue, as that solution wouldn't be limited to AdaptiveTheme. This does feel like a problem that would need to be solved for a lot of sites.

== EDIT ==

It looks like the "Skin base theme" option in the AT Theme Generator does what I was trying to describe with "sub-subthemes"

Skins are sub-sub themes that inherit extension, layout and color settings from their base theme. Select an existing theme as the skins base theme.

Try creating your main theme, create a few skins off of it and see if ThemeKey will use those :)

Jeff Burnz’s picture

Depends what you mean by "sections", some details there would help.

Try to give an example, e.g. is this a sections:http://www.aspergillus.org.uk/jobs (plus all the job nodes in that section etc etc?)

GAtherton’s picture

Hi Jeff thanks for your help.

Jobs is a single page but yes that is a content type we could give a distinct look. Larger sections might be 'Library' http://www.aspergillus.org.uk/library, 'Medical' http://www.aspergillus.org.uk/medical_information - in fact, most of the top items in the primary menu (top of page) could be sections. Each could have distinct colours (text/backgroup/template) and different header image and page layout so that someone landing on a page via Google will have some idea what section they have accessed straight away.

We are going to introduce collections of content that cut across content types so it is important that the viewer will be able to quickly tell whether they are looking at an article or conference abstract for example. I have given each content type a distinct and informative URL to assist with this process but employer also wants a distinct look.

The hint from jkovell to use multiple sub-themes and Themekey might be the answer for me, I currently use Pixture reloaded as a subtheme so all I would need to do is add more.

Jeff Burnz’s picture

ThemeKey is mega powerful on D7, so yes it's an option for sure, if it can provide the conditions that match your site/requirements.

Use light weight skin type themes, really they only need to be a css file (basically) that uses your default theme as a base theme.

mastoll’s picture

This may be a little late to the game, but have you looked at the module Page Theme? I'm using that to apply a different (than the default) AT sub-theme to one content type. I'm happy with it.

mastoll’s picture