localgovdrupal / localgov_microsites_base

Base theme for LocalGov Microsites
0 stars 1 forks source link

Set group active based on domain #5

Closed finnlewis closed 2 years ago

finnlewis commented 2 years ago

Currently we can't see the custom styling on the group / microsite url.

So going to https://localgov-micro-1.lndo.site/ does not activate the group and the colours are not overridden.

We need to implement this to be able to test and theme the config option.

@msayoung @markconroy @ekes ping!

finnlewis commented 2 years ago

See https://git.drupalcode.org/sandbox/ekes-3278349/-/blob/3.x/src/DomainGroupHelper.php#L58

ekes commented 2 years ago

So instead of just

    $parent_group_id = \Drupal::request()->attributes->get('group')->get('id')->value;

https://github.com/localgovdrupal/localgov_microsites_base/blob/a1441d091a422f7dfd603559a41059f430db4984/localgov_microsites_base.theme#L14

It can check for the group associated for the domain first.

  $parent_group_id = \Drupal::service('class_resolver')
    ->getInstanceFromDefinition(DomainGroupHelper::class)
    ->getActiveDomainGroup();
  if (empty($parent_group_id)) {
    $parent_group_id = \Drupal::request()->attributes->get('group')->get('id')->value;
  }

It'll need a use statement for the DomainGroupHelper::class

use Drupal\domain_group\DomainGroupHelper;
markconroy commented 2 years ago

Can we close this? I think it's been fixed in the mean time.