- Issue created by @Grevil
- 🇩🇪Germany Anybody Porta Westfalica
Yes I think that's a nice and helpful feature for cases where the app isn't the same as the project itself, but just part of the site, like
/app
or even/app/my-abc-app
- 🇩🇪Germany Anybody Porta Westfalica
I think the exclusion by path is the better and flexible enough approach? ✨ Exclude by content type Active
- Assigned to Grevil
- 🇩🇪Germany Grevil
I only really see one benefit in this. So that the "install app x" notification doesn't show up on "/mywebsite", but instead only on "/mywebsite/app".
We currently do not support multiple manifest.json's, which would be another benefit of this, as we could scope app1 in "/mywebsite/app1" and app2 in "/mywebsite/app2". And the rest of the scoping is done through "scope" and "start-url", should we postpone this issue in the future? Or is it really that important @Anybody?
- Status changed to Needs work
over 1 year ago 9:54am 12 September 2023 - 🇩🇪Germany Grevil
Just discussed this with @Anybody internally. This should be implemented!
- last update
over 1 year ago 1 pass, 2 fail - @grevil opened merge request.
- 🇩🇪Germany Anybody Porta Westfalica
Should be similar to the implementation of block visibility settings or here in etracker:
$form['tracking']['pages']['etracker_track_path_mode'] = [ '#type' => 'radios', '#title' => $this->t('Add tracking to specific pages'), '#options' => [ Constants::ETRACKER_TRACK_PATHS_MODE_ALL => $this->t('Every page except the listed pages'), Constants::ETRACKER_TRACK_PATHS_MODE_LISTED => $this->t('The listed pages only'), ], '#default_value' => $config->get('etracker_track_path_mode'), ]; $form['tracking']['pages']['etracker_track_paths'] = [ '#type' => 'textarea', '#title' => $this->t('Pages'), '#title_display' => 'invisible', '#default_value' => $config->get('etracker_track_paths'), '#description' => $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", [ '%blog' => '/blog', '%blog-wildcard' => '/blog/*', '%front' => '<front>', ]), '#rows' => 10, ];
/** * Tracking visibility check for pages. * * Based on visibility setting this function returns TRUE if JS code should * be added to the current page and otherwise FALSE. * * @param \Drupal\Core\Config\ImmutableConfig $config * A config object. * * @return bool * Returns TRUE if JS code should be added to the current page. */ function _etracker_path_should_be_tracked(ImmutableConfig $config) { $path_should_be_tracked = &drupal_static(__FUNCTION__); // Cache tracking result if function is called more than once. if (!isset($path_should_be_tracked)) { $visible_path_mode = $config->get('etracker_track_path_mode'); $visible_path_pages = $config->get('etracker_track_paths'); // Match path if necessary. if (!empty($visible_path_pages)) { // Convert path to lowercase. This allows comparison of the same path // with different case. Ex: /Page, /page, /PAGE. $pages = mb_strtolower($visible_path_pages); $path = Drupal::service('path.current')->getPath(); $path_alias = \Drupal::service('path_alias.manager')->getAliasByPath($path); if (empty($path_alias)) { $path_alias = mb_strtolower($path); } else { $path_alias = mb_strtolower($path_alias); } $page_match = \Drupal::service('path.matcher')->matchPath($path_alias, $pages) || (($path != $path_alias) && \Drupal::service('path.matcher')->matchPath($path, $pages)); // When $visible_path_mode has a value of 'all_pages', the tracking // code is displayed on all pages except those listed in $pages. When set // to 'all_listed', it is displayed only on those pages listed in $pages. $track_all_paths = ($visible_path_mode == Constants::ETRACKER_TRACK_PATHS_MODE_ALL); $path_should_be_tracked = ($track_all_paths xor $page_match); } else { $path_should_be_tracked = TRUE; } } return $path_should_be_tracked; }
- 🇩🇪Germany Grevil
Yep, already implemented the form based on the etracker implementation yesterday.
- last update
over 1 year ago 1 pass, 2 fail - last update
over 1 year ago 9 pass - last update
over 1 year ago 11 pass - Issue was unassigned.
- Status changed to Needs review
over 1 year ago 9:56am 13 September 2023 - 🇩🇪Germany Grevil
Done, works great! 🙂👍
Also added tests to verify its functionality. Please review!
- Status changed to Needs work
over 1 year ago 10:01am 13 September 2023 - Status changed to Needs review
over 1 year ago 10:08am 13 September 2023 - last update
over 1 year ago 11 pass - Status changed to RTBC
over 1 year ago 10:15am 13 September 2023 - last update
over 1 year ago 11 pass - Status changed to Fixed
over 1 year ago 10:16am 13 September 2023 Automatically closed - issue fixed for 2 weeks with no activity.