Post by tjsystems » Sun Jan 11, 2015 4:37 am

Hi all,

I'm building a OCmod to show the Europe map instead of the World map in de Admin Dashboard.

Somehow it's not all working, the change of the js-vmap works and also the language change. No errors in the logs.

I'm using the following code;

Code: Select all

<modification>
    <name>JQVMap Europe</name>
	<version>1.0</version>
	<author>NoSite.nl</author>
	<link>http://nosite.nl/</link>
	<code>admin_jqvmap_europe_ocmod</code>

	<file path="admin/view/template/dashboard/map.tpl">
		<operation error="log">
			<search <![CDATA[
			<script type="text/javascript" src="view/javascript/jquery/jqvmap/maps/jquery.vmap.world.js"></script>
			]]></search>
			<add position="replace"><![CDATA[
			<script type="text/javascript" src="view/javascript/jquery/jqvmap/maps/jquery.vmap.europe.js"></script>
			]]></add>
			<search ><![CDATA[
			<script type="text/javascript"><!--
$(document).ready(function() {
	$.ajax({
		url: 'index.php?route=dashboard/map/map&token=<?php echo $token; ?>',
		dataType: 'json',
		success: function(json) {
			data = [];
						
			for (i in json) {
				data[i] = json[i]['total'];
			}
					
			$('#vmap').vectorMap({
				map: 'world_en',
				backgroundColor: '#FFFFFF',
				borderColor: '#FFFFFF',
				color: '#9FD5F1',
				hoverOpacity: 0.7,
				selectedColor: '#666666',
				enableZoom: true,
				showTooltip: true,
				values: data,
				normalizeFunction: 'polynomial',
				onLabelShow: function(event, label, code) {
					if (json[code]) {
						label.html('<strong>' + label.text() + '</strong><br />' + '<?php echo $text_order; ?> ' + json[code]['total'] + '<br />' + '<?php echo $text_sale; ?> ' + json[code]['amount']);
					}
				}
			});			
		},
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
	});			
});
//--></script>
			]]></search>
			<add position="replace"><![CDATA[
			<script type="text/javascript"><!--
$(document).ready(function() {
	$.ajax({
		url: 'index.php?route=dashboard/map/map&token=<?php echo $token; ?>',
		dataType: 'json',
		success: function(json) {
			data = [];
						
			for (i in json) {
				data[i] = json[i]['total'];
			}
					
			$('#vmap').vectorMap({
				map: 'europe_en',
				backgroundColor: '#FFFFFF',
				borderColor: '#FFFFFF',
				color: '#9FD5F1',
				hoverOpacity: 0.7,
				selectedColor: '#666666',
				enableZoom: true,
				showTooltip: true,
				values: data,
				normalizeFunction: 'polynomial',
				onLabelShow: function(event, label, code) {
					if (json[code]) {
						label.html('<strong>' + label.text() + '</strong><br />' + '<?php echo $text_order; ?> ' + json[code]['total'] + '<br />' + '<?php echo $text_sale; ?> ' + json[code]['amount']);
					}
				}
			});			
		},
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
	});			
});
//--></script>
			]]></add>
		</operation>
	</file>
	
	<file path="admin/language/english/dashboard/map.php">
		<operation error="log">
			<search ><![CDATA[
			$_['heading_title'] = 'World Map';
			]]></search>
			<add position="replace"><![CDATA[
			$_['heading_title'] = 'Europe Map';
			]]></add>
		</operation>
	</file>
</modification>
Doing the whole piece of js, also tested just with the line #25.
Any tips/solutions/etc?
Thanks!
Last edited by tjsystems on Mon Jan 12, 2015 4:37 am, edited 1 time in total.

Live with 2.2.0.0 fully SSL.


Active Member

Posts

Joined
Sun Aug 26, 2012 5:39 pm
Location - NL, Amsterdam

Post by rph » Sun Jan 11, 2015 9:20 am

Your XML is broken and you're using multi-line searches instead of single line. An OCmod script should also change as little as possible. Here's how the mod should look:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<modification>
	<name>JQVMap Europe</name>
	<version>1.0</version>
	<author>NoSite.nl</author>
	<link>http://nosite.nl/</link>
	<code>admin_jqvmap_europe_ocmod</code>
	<file path="admin/view/template/dashboard/map.tpl">
		<operation error="log">
			<search><![CDATA[src="view/javascript/jquery/jqvmap/maps/jquery.vmap.world.js"]]></search>
			<add position="replace"><![CDATA[src="view/javascript/jquery/jqvmap/maps/jquery.vmap.europe.js"]]></add>
		</operation>
		<operation>
			<search><![CDATA[map: 'world_en',]]></search>
			<add position="replace"><![CDATA[map: 'europe_en',]]></add>
		</operation>
	</file>
	<file path="admin/language/english/dashboard/map.php">
		<operation error="log">
			<search><![CDATA['World Map']]></search>
			<add position="replace"><![CDATA['Europe Map']]></add>
		</operation>
	</file>
</modification>

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by tjsystems » Mon Jan 12, 2015 4:36 am

Thanks for the support, it's working fine!

Live with 2.2.0.0 fully SSL.


Active Member

Posts

Joined
Sun Aug 26, 2012 5:39 pm
Location - NL, Amsterdam
Who is online

Users browsing this forum: No registered users and 1 guest