jimie VIP
Total posts: 531
16 Сен 2014 11:42

Hello Sergey,

A new round for optimizing the website today and I found that this script:

<script src="//maps.googleapis.com/maps/api/js?language=en&region=GB&key=&sensor=true&libraries=weather,panoramio,visualization,traffic,places" type="text/javascript"></script>

Is always loaded on the website. and it found it comes from this:

library/php/helpers/helper.php

On the website we use cobalt records module to display latest listings submitted on the website, customized the template to show only the title with link to those listings so no google map need to be load on the website homepage.

Do you think is possible to add an option where you can select the menu item where you don't want that script loaded ?

Regards

Последние изменения: 24 Сен 2014


Sergey
Total posts: 13,748
17 Сен 2014 01:25

Actualy we call this methog only if map is supposed to be displaied. May be you simply not show it in template but in parameters it is turned on to be displaied. Also gallery field sometimes load this.


jimie VIP
Total posts: 531
17 Сен 2014 04:54

Hello

May be you simply not show it in template but in parameters it is turned on to be displaied.

Can you be more specific please in what template exactly are you talking about ? section template, type template or field template ?

Rgds


Sergey
Total posts: 13,748
18 Сен 2014 03:33

This is not on template only. For example field parameters. I do not know your setup that is why I cannot say. DO you use custom template for geo field output in the list? Also that may be filter which loads this script.

Inother words if it is there, most probably it is in use.


jimie VIP
Total posts: 531
18 Сен 2014 05:32

Oky that seams to be gone, when I go and set "Show in intro" to "NO" for geo field, but I need that to be showed on the sections areas, what do you think I can do ?

Rgds


Sergey
Total posts: 13,748
18 Сен 2014 09:47

If it needs to be shown, then there is a chance that it will be needed right? I mean how can I switch it off on the page where it needs to be shown?


jimie VIP
Total posts: 531
18 Сен 2014 10:19

The field is needed in sections area but not in module listings.

Maybe a way to override the option in the module template override, I see there`s an option to set what fields to exclude but even if I select the geo field in there, it still does not helps.

Rgds


Sergey
Total posts: 13,748
18 Сен 2014 10:29

I see. Unfortunately hard to do anything in this situation.


jimie VIP
Total posts: 531
24 Сен 2014 10:27

Hello Sergey,

What if you can add a check something like:

if ( view==homepage ) {

dont load script

} esle {

load script

}

Rgds


jimie VIP
Total posts: 531
24 Сен 2014 11:07

Oky i fixed with this:

 $menu = $app->getMenu();
                if ($menu->getActive() == $menu->getDefault()) {
                }

                else {
                JFactory::getDocument()->addScript('//maps.googleapis.com/maps/api/js?language=' . $lang . '&region=' . $region . '&key=' . $map_key . '&sensor=true&libraries=weather,panoramio,visualization,traffic,places');

                $loaded = 1;
                }

Работает на Cobalt