Closed dahaupt closed 1 year ago
Hi, you can use the TypoScript Setting plugin.tx_gomapsext.preview.enabled = 1. So the Api is not included directly. Then override the partial Resources/Private/Partials/Preview.html. Otherwise how would a good solution for you look like? You can also write on slack.
Hey @mhirdes, thanks for your feedback!
I am aware of the preview functionality, but IMO the extension (or extensions in general) should not each include an individual opt-in mechanism as this should be primarily the task of a cookie consent tool. If each extension handles this on its own, configuration for those consent tools is more complex than it should be.
In my world, a cookie consent tool:
Basically each functionality described above is more or less already integrated into the extension. In general, I would recommend to remove the functionality and refer to the use of a cookie consent tool. However, this simple preview might be sufficient for many smaller projects without many cookies and services.
In order to make the integration for cookie consent tools easier, I would propose to:
plugin.tx_gomapsext.settings.enableOptInMode
:
<script data-src="{src}" data-name="{serviceName}" type="text/plain"></script>
so they are not loaded anymore at all.data
attributes. This method should be as simple as possible and will be called by the consent tool.Looking forward to your feedback! (Slack: dahaupt)
Hi @dahaupt,
sry for the late response. I checked again the current preview mode. To overwrite the partial and take a look at the jquery.gomapsext.preview.js it's a good example how to initialize the map. Of course costumization is needed.
But I wrote you an slack today. May we can write there to find a good solution.
May I ask if you two have found a solution in your Slack discussion?
@deadmanIsARabbit Unfortunately, I have not responded back to @mhirdes, yet. Will try to find the time to look into this topic again!
Hey @mhirdes and @dahaupt, I got the same question as @deadmanIsARabbit, ran into the same issue some days ago and it would be great to see a solution coming. Until this will happen I have to find a workaround for this issue.
Currently this appears in combination with the cookieman extension.
If somebody got the same issue, I want to quickly describe a workaround for you to get GoMapsExt working in preview mode running together with a cookie consent tool. In my case it was Cookieman.
You need to overwrite the ScriptViewHelper, because you need to change the following things for the script tag generation. (Done it via registration of an XClass)
src
attribute should be changed to data-src
type="text/javascript"
to type="text/plain"
Add data-name
attribute with the value "googleMapCE"
Dahaupt's solution looks like this:
$tempJavaScriptFile = GeneralUtility::writeJavaScriptContentToTemporaryFile($this->renderChildren());
GeneralUtility::makeInstance(PageRenderer::class)
->addFooterData('<script data-src="' . $tempJavaScriptFile . '" type="text/plain" data-name="googleMapCE"></script>');
Enable the include_google_api_manually
setting, because it will get injected later through showMap()
function inside jquery.gomapsext.preview.js
(showMap()
will be called when you click the preview link)
Inject the following JS snipped when consent, it will load the GoMapsExt scripts and you're ready to go!
<script>
const $element = $('.tx-go-maps-ext');
if ($element) {
$.when($.getScript('/typo3conf/ext/go_maps_ext/Resources/Public/Scripts/markerclusterer_compiled.js'),
$.getScript('/typo3conf/ext/go_maps_ext/Resources/Public/Scripts/jquery.gomapsext.js'),
$.Deferred(function (deferred) {
$(deferred.resolve);
})).done(function () {
$('script[data-name="googleMapCE"]').each(function () {
$.getScript($(this).data('src'));
});
});
}
</script>
Now your preview link will show the maps after clicked.
- ScriptViewHelper
Can you descripe it more detailed, were can i find the "ScriptViewHelper" on filesystem and how to override it? Copy code on a special place in this file? Or is there another way, to keep cookieman ready for future updates without override you workaround.
You don't need to overwrite the script ViewHelper. The tempJavaScriptFile dosen't load any external function.
You can set in the extension manager config, that you load the JS by your own, if the preview function as it self works not for you.
If any other help is needed for this topic, please contact me on slack
Cookie consent tools often have the requirement to add specific data-attributes (e.g.
data-src
anddata-name
) in order to load scripts only when consent is given.Currently it seems necessary to override
MapController->initializeAction
andScriptViewHelper->render
to correctly include the scripts with necessary data-attributes (usingPageRenderer->addFooterData
).Another current challenge is to include the scripts in the correct order. Would be awesome to ease this afford and allow easy integration into third-party consent management tools.