Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Help - Missing Code

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sat Sep 08, 2018 4:24 am    Post subject: Help - Missing Code Reply with quote

Hello. Ive got an odd problem here... I have no idea if its javascript, PHP or smarty., but i think its Smarty.

basically, Ive got javascript code on my site to display a Google map with coordinates. You click on the icons on the map & it displays information about that icon on the right of the screen..

Everything seemed to be working, However i noticed today that SOME icons dosplayed correctly - 7 put the information inside the right-side div.

However if i click on other - the WHOLE webpage is displayed inside the second div. (it repeats itself).

My main browser is OPERA. so i tried on Mozilla Firefox and everything looks fine/OK as it should (i even clicked on the same icons - Mozilla produced the correct result.

Eventually - looking at the HTML source code - The Mozilla Firefox shows the full HTMl source code. But Opera was missing ALL of the icons data.. I refreshed - refreshed, cleared cache & refreshed & still same result.


http://animals.kwister.com/directory/

if you choose NORTHLAND as a region - 2 icons should show. AUCKLAND has more.

Here is the Smarty code (extract) - the foreach loop is the part that sjows the icon data.

has anyone got an idea as to why one browser displays data & the other doesnt ? PS ive got NO PHP (or other) code that distinguishes between any browser & does a different thing.


Code:

<!-- Start mapcode -->
{literal}
<script type="application/javascript">
      function initMap() {
        var map = new google.maps.Map(document.getElementById('map'), {
          zoom: 3,
          center: {lat: -36.880332352941,  lng: 174.79771417647}
        });
        // Create an array of alphabetical characters used to label the markers.
        var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

        // Add some markers to the map.

var infoWin = new google.maps.InfoWindow();
var markers = locations.map(function(location, i) {
  var marker = new google.maps.Marker({
    position: location
  });
 google.maps.event.addListener(marker, 'click', function(evt) {
     $('#sidebar2').load('/direct_proc.php?out=' + location.info);
   });

  return marker;
});

// Add a marker clusterer to manage the markers.
        var markerCluster = new MarkerClusterer(map, markers,
            {imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
      }
     
{/literal}
var locations = [
{foreach from=$mapcoordinates key=k1 item=v1}
{if isset($v1.geo1)}
{if isset($v1.geo2)}
{literal}{{/literal}lat: {$v1.geo1},  lng: {$v1.geo2}, info:"{$k1}"{literal}}{/literal}, 
{/if}
{/if}
{/foreach}
      ]
    </script>
    <script src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js">
    </script>
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDsY72KpoRA5_8hY2Y_NCxXZ5Yhx62PRaQ&callback=initMap">
    </script>
<!-- end mapcode -->
Back to top
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sat Sep 08, 2018 4:49 am    Post subject: Reply with quote

Hmm

After 30+ minutes of trying things (i didnt do anything - i remember) - it is now working on both browsers)...
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Sep 08, 2018 1:17 pm    Post subject: Reply with quote

You don't need to cover your JS/HTML code in {literal}'s - just add a space after opening delimiter to distinguish Smarty code from the rest. Extra spaces will be eaten by the parser.
The only code I wrap in {literal}'s is foreign snippets, like banners. And they are in external {include}'d files.
Back to top
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sun Sep 09, 2018 1:36 am    Post subject: Reply with quote

AnrDaemon wrote:
You don't need to cover your JS/HTML code in {literal}'s - just add a space after opening delimiter to distinguish Smarty code from the rest. Extra spaces will be eaten by the parser.
The only code I wrap in {literal}'s is foreign snippets, like banners. And they are in external {include}'d files.


Thanks - I will remember that in future...
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP