Problem/Motivation

Module hardcodes filename for delivered JS but for http://dgo.to/domain it needs separate files.
I guess the same required to handle core's multisiting

Proposed resolution

Add custom hook to alter generated filename or store filename on config to allow config overrides to take over fine name

Remaining tasks

Discuss solution, create patch & commit

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

ilya.no’s picture

There is a patch for basic support without using hook. Just checking, whether domain module is enabled and getting active domain id for adding it to the filename.

andypost’s picture

Status: Active » Needs review

Great workaround but it needs a bit more work to be accepted

SpadXIII’s picture

Re-rolled the patch against latest dev.

I agree it's a workaround and it should be something more permanent. Instead of having a dependency on domain, an alter to change the filenames would be better.

Though I'm not sure why each domain should have a unique js file.

SpadXIII’s picture

FileSize
4.71 KB

And of course I forgot to attach a new patch...

dennisvdberg91’s picture

@spadXlll @andypost

I would appreciate if this does not create like files for every domain, since there are websites with many domains.

Im not sure if this is what your patch does? what are your thoughts?

solotandem’s picture

Status: Needs review » Postponed

The patch is unacceptable [no patch should be necessary].

What needs to be done first is for Drupal 8 core to fully implement the 7.x variable project (including variable_realm module) and implement realms properly with an UI, etc. instead of the half-baked partial implementation that exists. [The last I checked this had not been done. If someone knows otherwise please comment.]

Next we restore the 7.x realm functionality of this module. Last, you add a domain realm and configure your sites, all without any special code changes for the domain integration.

andypost’s picture

Status: Postponed » Needs review

This issue for 8.x

solotandem’s picture

Status: Needs review » Postponed

@andypost Please read what I wrote. It only refers to 8x.

andypost’s picture

Status: Postponed » Needs review

Ah, you mean to adopt realm... but core 8 already implements overrides for config & that's what domain module using now

So looking at patch all we need is configurable file patch,
means that file name should use "path-template" that should be stored in config for domain overrides

andypost’s picture

Issue tags: +Needs tests
FileSize
6.03 KB
3.24 KB

I think there could be compromise with this patch as approach

- Adds separate setting snippets_path_prefix that required to have variations of path per domain or whatever
- Settings form will affect only one domain and needs test
- No update hook yet

ayalon’s picture

@andypost:
The latest path is not working. I had to change it:

  public function saveSnippets() {
    // Save the altered snippets after hook_google_tag_snippets_alter().
    module_load_include('inc', 'google_tag', 'includes/snippet');
    $result = TRUE;
    $snippets = google_tag_snippets();
    // Allow to use config overrides to help vary snippets per domain.
    $prefix = \Drupal::config('google_tag.settings')
      ->get('snippets_path_prefix');

If you use $this->config('google_tag.settings') it is not domain sensitive. I was not able to figure out why.

piggito’s picture

FileSize
4.16 KB
1.27 KB

Normally, after saving settings form the snippet file should be created with the defined prefix. However, this wasn't working cause there isn't a form element for the snippets_path_prefix setting.
I'm adding a form element and including this new setting for config save on submitForm.

ptmkenny’s picture

solotandem’s picture

@andypost et al Do the five recent commits to enable multiple containers provide a solution for the domain context? Can you create a container for each domain and use the config override capability from core to set the correct one? And disable the others? Or remove the other domain items from the attachments added to the page render array?

See #3035196-9: Add support for multiple containers.

santhosh.fernando’s picture

Do we have instructions on how this patch should works with domains? Do we have a path forward on how this should work?

solotandem’s picture

@santosh Are you referring to patch in #13? If so, did you read my comment in #15? It suggests that a patch is not necessary but that the latest development release should support domain.

solotandem’s picture

Assigned: Unassigned » solotandem
Category: Task » Feature request
Status: Needs review » Fixed

The dev release includes the ability to create multiple containers. Among the commits pushed today is a domain condition plugin that allows you to select the domains to which a container applies.

andypost’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.