Giter Club home page Giter Club logo

Comments (10)

dahaupt avatar dahaupt commented on September 14, 2024 3

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:

  • stores the necessary cookie to decide if a service (in this case Google Maps) is accepted
  • evaluates the state of a service and triggers the loading of scripts or necessary methods
  • shows an opt-in-banner in case consent was not given (including option to accept once or permanently)

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:

  • Add a new TypoScript constant: plugin.tx_gomapsext.settings.enableOptInMode:
    • This mode changes all scripts to <script data-src="{src}" data-name="{serviceName}" type="text/plain"></script> so they are not loaded anymore at all.
    • This constant could be set automatically by cookie consent extensions, which "officially" support this extension.
    • Using this mode, the initialization of the map must be triggered manually (e.g. by cookie consent tool).
  • Add a method to initialize a map (e.g. by providing the id of the element "#gme-1"). This method could alternatively also fetch all necessary scripts instead of adding 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)

from go_maps_ext.

bardimardy avatar bardimardy commented on September 14, 2024 1

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.

from go_maps_ext.

mhirdes avatar mhirdes commented on September 14, 2024

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.

from go_maps_ext.

mhirdes avatar mhirdes commented on September 14, 2024

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.

from go_maps_ext.

deadmanIsARabbit avatar deadmanIsARabbit commented on September 14, 2024

May I ask if you two have found a solution in your Slack discussion?

from go_maps_ext.

dahaupt avatar dahaupt commented on September 14, 2024

@deadmanIsARabbit Unfortunately, I have not responded back to @mhirdes, yet. Will try to find the time to look into this topic again!

from go_maps_ext.

bardimardy avatar bardimardy commented on September 14, 2024

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.

from go_maps_ext.

ProWebs avatar ProWebs commented on September 14, 2024
  • 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.

from go_maps_ext.

mhirdes avatar mhirdes commented on September 14, 2024

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.

from go_maps_ext.

mhirdes avatar mhirdes commented on September 14, 2024

If any other help is needed for this topic, please contact me on slack

from go_maps_ext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.