Jump to content

how can I enter the email in the globe?


Recommended Posts

Wow, that took some time to find... here we go:

 

 

Override the storescontroller, found in /controllers/front/storescontroller.php

Then change in this class:

 

Find the function displayAjax() and add to this a line:

 

 

 

protected function displayAjax()

{

 

$stores = $this->getStores();

$dom = new DOMDocument('1.0');

$node = $dom->createElement('markers');

$parnode = $dom->appendChild($node);

 

$days[1] = 'Monday';

$days[2] = 'Tuesday';

$days[3] = 'Wednesday';

$days[4] = 'Thursday';

$days[5] = 'Friday';

$days[6] = 'Saturday';

$days[7] = 'Sunday';

 

foreach ($stores as $store)

{

$other = '';

$node = $dom->createElement('marker');

$newnode = $parnode->appendChild($node);

$newnode->setAttribute('name', $store['name']);

$address = $this->processStoreAddress($store);

 

$other .= $this->renderStoreWorkingHours($store);

$newnode->setAttribute('addressNoHtml', strip_tags(str_replace('<br />', ' ', $address)));

$newnode->setAttribute('address', $address);

$newnode->setAttribute('other', $other);

$newnode->setAttribute('phone', $store['phone']);

$newnode->setAttribute('email', $store['email']); //add this line

$newnode->setAttribute('id_store', (int)($store['id_store']));

$newnode->setAttribute('has_store_picture', file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg'));

$newnode->setAttribute('lat', (float)($store['latitude']));

$newnode->setAttribute('lng', (float)($store['longitude']));

if (isset($store['distance']))

$newnode->setAttribute('distance', (int)($store['distance']));

}

 

header('Content-type: text/xml');

die($dom->saveXML());

}

 

 

 

 

The second adjustment is in file:

 

/themes/<your theme folder>/js/stores.js

 

find the function initMarkers() and add the red changes:

 

function initMarkers()

{

searchUrl += '?ajax=1&all=1';

downloadUrl(searchUrl, function(data) {

var xml = parseXml(data);

var markerNodes = xml.documentElement.getElementsByTagName('marker');

var bounds = new google.maps.LatLngBounds();

for (var i = 0; i < markerNodes.length; i++)

{

var name = markerNodes.getAttribute('name');

var address = markerNodes.getAttribute('address');

var addressNoHtml = markerNodes.getAttribute('addressNoHtml');

var other = markerNodes.getAttribute('other');

var email = markerNodes.getAttribute('email');

var id_store = markerNodes.getAttribute('id_store');

var has_store_picture = markerNodes.getAttribute('has_store_picture');

var latlng = new google.maps.LatLng(

parseFloat(markerNodes.getAttribute('lat')),

parseFloat(markerNodes.getAttribute('lng')));

createMarker(latlng, name, address, other, id_store, has_store_picture, email);

bounds.extend(latlng);

}

});

}

 

 

do the same for function:

 

function searchLocationsNear(center)

{

var radius = document.getElementById('radiusSelect').value;

var searchUrl = baseUri+'?controller=stores&ajax=1&latitude=' + center.lat() + '&longitude=' + center.lng() + '&radius=' + radius;

downloadUrl(searchUrl, function(data) {

var xml = parseXml(data);

var markerNodes = xml.documentElement.getElementsByTagName('marker');

var bounds = new google.maps.LatLngBounds();

 

clearLocations(markerNodes.length);

for (var i = 0; i < markerNodes.length; i++)

{

var name = markerNodes.getAttribute('name');

var address = markerNodes.getAttribute('address');

var addressNoHtml = markerNodes.getAttribute('addressNoHtml');

var other = markerNodes.getAttribute('other');

var distance = parseFloat(markerNodes.getAttribute('distance'));

var id_store = parseFloat(markerNodes.getAttribute('id_store'));

var phone = markerNodes.getAttribute('phone');

var email = markerNodes.getAttribute('email');

var has_store_picture = markerNodes.getAttribute('has_store_picture');

var latlng = new google.maps.LatLng(

parseFloat(markerNodes.getAttribute('lat')),

parseFloat(markerNodes.getAttribute('lng')));

 

createOption(name, distance, i);

createMarker(latlng, name, address, other, id_store, has_store_picture, email);

bounds.extend(latlng);

...

 

}

 

 

Finally change the function:

 

function createMarker(latlng, name, address, other, id_store, has_store_picture, email)

{

var html = '<b>'+name+'</b><br/>'+address+'<br/>'+email+(has_store_picture === 1 ? '<br /><br /><img ...

 

...

}

 

That should do it.

 

 

 

Don't forget to NOT change it in the original controller file directly, but neatly override it first, to make upgrading to new PS versions SOO much easier. (For how to override controllers and other files, see development guide in docs.prestashop.com)

 

Hope this helped,

Pascal.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...