Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Store Locator?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #11  
Old 03-17-2011, 02:11 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Store Locator?

It only works with PHP4, sadly. If your host supports it, you can revert to PHP4 by adding a php.ini file in the locator directory with this line of code...

Code:
Addtype x-mapp-php4 .php

The project was abandoned, so we can only provide minimal (if any) support for it.
__________________
xcartmods.co.uk
Reply With Quote
  #12  
Old 06-10-2011, 01:48 AM
 
bionuts bionuts is offline
 

Senior Member
  
Join Date: Oct 2008
Posts: 109
 

Default Re: Store Locator?

I'm having issues with this mod, too. It's really frustrating, as it's almost perfect for what we need.

Our host don't support PHP4, for security reasons, so I can't use PhilJ's suggested solution. However, the only problem I really can't workaround is that this error message is displayed when a search does not find any locations:

"Warning: Invalid argument supplied for foreach() in /home/healthpl/public_html/locator/phpGoogleStoreLocator-javascripts.php on line 37"If I can find some way of stopping that message from appearing, then I can continue to use the mod - even if other parts (like category searches) are not working properly.

This is the file that the error message refers to:

PHP Code:
<?php
//Javascript popup window
   
$javascript "
   <SCRIPT LANGUAGE=\"JavaScript\">
   function popUp(URL,width,height) 
   {
   day = new Date();
   id = day.getTime();
   eval(\"page\" + id + \" = window.open(URL, '\" + id + \"', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,'+width+','+height+',left = 112,top = 84');\");
   }
   </script>
   <script src=\"http://maps.google.com/maps?file=api&v=2.x&key=
{$this->google_key}\" type=\"text/javascript\"></script>
   "
;

   
//This loads the pdmarker extension for googlemaps markers to give snazzy abilities to the markers.
   
$javascript .= "<SCRIPT LANGUAGE='JavaScript'>".load_file('pdmarker.js')."</script>";
   
$javascript .= "
      <div id='pdmarkerwork'></div>
   <script type='text/javascript'>
   //<![CDATA[
   //window.onload = onPageLoad;
   onPageLoad();
   var map;
   function onPageLoad() {
      if (GBrowserIsCompatible()) {
      "
;

      
//Create the map itself and center it on the "you" icon
      
$javascript .= $this->create_map($this->search_form_object->center_lat_lon'''NORMAL');

      
//Add the "You" icon
      
$javascript .= $this->create_map_marker($this->search_form_object->center_lat_lon'You''-1''You'$this->get_icon('you'), $this->get_icon('you'), 'you');

      
$marker_id 0;
      
//Add all the results icons
      
foreach ($this->results AS $location)
      {
      
$coordinates->lat $location->lat;
      
$coordinates->lon $location->lon;
      
$street           trim(addslashes($location->street));
      
$city             trim(addslashes($location->city));
      
$state            trim(addslashes($location->state));
      
$zip              addslashes($location->zip);
      
$country          addslashes($location->country);
      
$storename        addslashes($location->storename);
      
$hours            addslashes($location->hours);
      
$url              addslashes($location->url);
      
$image            addslashes($location->image);
      
$notes            addslashes(wordwrap($location->notes80"<br>"));
      
$phone            addslashes($location->phone);
      
$id               $location->id;
      
$image_url        addslashes($location->image_url);
      
$distance         number_format($location->distance,2'.''');
      
$icon             $this->get_icon($id);
      
$marker_id        $location->marker_id;

      
//Set a css width for the balloon window based on the street address or storename, which over is larger.
      
$css_width strlen($street) * 10;
      
$css_width2 strlen(strip_tags($storename)) * 10;

      if (
$css_width $css_width2) { $css_width $css_width2; }

      
//if there is image and display for it is on, adjust the width and add 10 for the padding of the image
      
if ($image && $this->get_setting('display_image_in_balloon') == 'on')
      {
      list(
$width$height$type$attr) = getimagesize("$mapicon");
      
$css_width $width $css_width 10;
      }

      
//Create the HTML for this Location's Marker Icon Info Window
      
$html  "<div id=markerTooltip style='width:$css_width"."px;' class=phpGoogleStoreLocator_map_balloon_body>";
      if (
$image && $this->get_setting('display_image_in_balloon') == 'on')
                  {
                     
$html .= "<div class=phpGoogleStoreLocator_map_balloon_image>$image</div>";
                  }
      if (
$url == '') { $html .= "<b>".strip_tags($storename)."</b><br>"; }
      if (
$url != '') { $html .= "<b><a href=http://$url>".strip_tags($storename)."</a></b><br>";    }
      
$html .= "$street<br>";
      
$html .= "$city ";
      if (
$state)     { $html .= "$state, "; }
      
$html .= "$zip ";
      
$html .= "$country<br>";
      
$html .= "$hours<br>";
      
$html .= "$notes";
      
$html .= "</div>";

      
$javascript      .= $this->create_map_marker($coordinatesstrip_tags($storename), $marker_id$html$icon$icon); 
      
$javascript      .= "\n\n";

      }

     if (
$this->get_setting('use_autozoom') == 1)
      {
        
$javascript .= "map.zoomToMarkers();";
      }

      
$javascript .= "\n      }   }   //]]>   </script>";
      
      
//This is a trick to pre-load the map marker icon.  It's used for loading the map before any results images which
      //can take a very long time to load especially if every single result has an image.
      
if (!$_POST['xml'] && !$_GET['xml'])
      {
?>
<!--This is a trick to pre-load the map marker icon.  It's used for loading the map before any results images which
      //can take a very long time to load especially if every single result has an image. !-->
<img src="<?php echo $icon?>" style="display:none;" />
<?
}
?>


The section the error message is referring to starts at "//Add all the results icons".

If anyone has any suggestions how I can change this to stop the error message coming up, or how I can change it to stop the error happening in the first place, I'd be grateful.
__________________
Four sites using X-Cart 5.4.x.x. Oh the joy
Reply With Quote
  #13  
Old 06-13-2011, 09:16 AM
 
bionuts bionuts is offline
 

Senior Member
  
Join Date: Oct 2008
Posts: 109
 

Default Re: Store Locator?

I managed to answer my own question.

To stop the error coming up, I changed this line:

PHP Code:
foreach ($this->results AS $location

to this:

PHP Code:
foreach((array)$this->results AS $location

I don't know whether this is suppressing the error or solving the problem that was causing the error to come up but the end result is what I wanted, so I'm going to leave it at that.

You can see the Store Locator in action at www.healthplus.co.uk/locator.php.
__________________
Four sites using X-Cart 5.4.x.x. Oh the joy
Reply With Quote

The following user thanks bionuts for this useful post:
PhilJ (06-14-2011)
  #14  
Old 01-18-2012, 07:26 AM
  JeanB's Avatar 
JeanB JeanB is offline
 

eXpert
  
Join Date: Oct 2009
Location: Worcestershire, UK
Posts: 217
 

Default Re: Store Locator?

Oh, this is so annoying ... !

I've got this to work exactly as I need - it's great!

But I cannot edit the templates!?



As soon as I edit something in a template the whole thing disappears!!

So I "Undo" and put it back to what it should be and it's still not there!!


Now, I realise it sounds like I'm doing something silly, but all I did was remove a line of text, or remove a <tr> from a table. So - I just commented something out instead, but that didn't work at all!

If anyone has any idea what on earth is going on here, I'll be more than grateful!
__________________
4.2.3
X-Cart Gold
BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers
-------[installed]----------------------[installed]--------------[installed]----[installed]--



5: in development
Reply With Quote
  #15  
Old 01-18-2012, 07:40 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Store Locator?

Have you tried clearing the cache? Some of the line you are deleting may actually be needed for the result output, or check in firbug if the result is there but off the page or something. Or you can use this - http://www.cflsystems.com/store-locator-mod-for-x-cart.html
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #16  
Old 01-18-2012, 08:06 AM
  JeanB's Avatar 
JeanB JeanB is offline
 

eXpert
  
Join Date: Oct 2009
Location: Worcestershire, UK
Posts: 217
 

Default Re: Store Locator?

I've tried clearing the cache and looked in Firebug, but there's just no content at all. I put everything back to as it was and it's still not working.

The only way I can get it to work afterwards is to re-upload everything!


Steve ... I think you're right! I will go ahead and buy that.

Would this work on 4.2.3?

Also - are the little location markers customisable? (That's the clincher, lol)
__________________
4.2.3
X-Cart Gold
BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers
-------[installed]----------------------[installed]--------------[installed]----[installed]--



5: in development
Reply With Quote
  #17  
Old 01-18-2012, 08:10 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Store Locator?

If something doesn't work I'll help you make it work on 4.2.x. You can assign your own images to marker locations yes
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #18  
Old 01-18-2012, 08:15 AM
  JeanB's Avatar 
JeanB JeanB is offline
 

eXpert
  
Join Date: Oct 2009
Location: Worcestershire, UK
Posts: 217
 

Default Re: Store Locator?

Legend! - Thanks

I'll sort that now - Excellent news on the marker - that makes me very happy!
__________________
4.2.3
X-Cart Gold
BCSE Address Book | XCartMods QuickFind | X-RMA | X-Offers
-------[installed]----------------------[installed]--------------[installed]----[installed]--



5: in development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:04 PM.

   

 
X-Cart forums © 2001-2020