Categories

Hello World;)

All articles that you can find here We wrote for our customers or for us selfs. We using this blog as future data base for quick and clean solutions for common problems.

Feel free to give us your opinion.

I hope that is useful for you as well.

Thanks

Googlemaps plugin – multiple markers

Here is a way to modify free Googlemaps Plugin to draw multiple markers on your joomla site (joomla 1.5).

First of all you need to get your plugin. You can find it here. Now install and active.

 

Fun will begin from this point:)

Usage of plugin:

{mosmap address='151 London Road, Edinburgh, UK'|icon='http://tech.reumer.net/images/demo.png'}

For more examples of how to use Googlemaps plugin visit developer's site.

Using basic version of plugin we can past only one address, description and image. My task was rewrite code to enable passing multiple addresses, descriptions and images for one map. What I'm trying to achieve is:

{mosmap address[0]='151 London Road, Edinburgh, UK'|txt[0]='Our office'|pic[0]='http://www.expandingweb.com/blog/wp-content/uploads/2010/07/favicon_3.jpg'|address[1]='42 Roseburn Street, Edinburgh, UK'|txt[1]='Description of place'| pic[1]='http://www.expandingweb.com/blog/wp-content/uploads/2010/07/favicon_3.jpg'}

 

We need to find files which is responsible for reading arguments and drawing map. Fortunately there is only one file that we need to edit:)

It's  "your_site/plugins/system/plugin_googlemap2.php":
378

  1. / Parameters can get the default from the plugin if not empty or from the administrator part of the plugin
  2. $width = $this->params->get( 'width', '100%' );
  3. $height = $this->params->get( 'height', '400px' );
  4. $deflatitude = $this->params->get( 'lat', '52.075581' );
  5. $deflongitude = $this->params->get( 'lon', '4.541513' );
  6. $centerlat = $this->params->get( 'centerlat', '' );
  7. $centerlon = $this->params->get( 'centerlon', '' );
  8. //$address = $this->params->get( 'address', '' );
  9. $zoom = $this->params->get( 'zoom', '10' );

Comment line which contains address declaration. It takes $address value from back end panel.

Now it needs to be declared the way we want ( as array). Go to line 523 and add those lines:

$address = array();
$image = array();
$message = array();

so you'll receive something like this:
514

  1. // default empty and should be filled as a parameter with the plugin out of the content item
  2. $code='';
  3. $lbcode='';
  4. $lang = $this->language;
  5. $mapclass='';
  6. $tolat='';
  7. $tolon='';
  8. $toaddress='';
  9. $description='';
  10. $tooltip='';
  11. $address = array();
  12. $image = array();
  13. $message = array();
  14. $kml = array();
  15. $kmlsb = array();
  16. $layer = array();
  17. $lookat = array();
  18. $camera = array();

 

Next step will be read values for our variables. We need to put some extra code for read values and insert them into array.

We'll begin our coding around line 690. Try to find

else if($values[0]=='lang'){
$lang=$values[1];
}

and after it place this code:

else if($values[0]=='address'){
	$address[0]=trim($values[1]);
}else if(($this->brackets=='both'||$this->brackets=='[')&&preg_match("/address\([0-9]+\)/", $values[0])){
	$address[$this->_get_index($values[0], '(')] = trim($values[1]);
}else if(($this->brackets=='both'||$this->brackets=='{')&&preg_match("/address\[[0-9]+\]/", $values[0])){
	$address[$this->_get_index($values[0], '[')] = trim($values[1]);
}else if($values[0]=='pic'){
	$image[0]=trim($values[1]);
}else if(($this->brackets=='both'||$this->brackets=='[')&&preg_match("/pic\([0-9]+\)/", $values[0])){
	$image[$this->_get_index($values[0], '(')] = trim($values[1]);
}else if(($this->brackets=='both'||$this->brackets=='{')&&preg_match("/pic\[[0-9]+\]/", $values[0])){
	$image[$this->_get_index($values[0], '[')] = trim($values[1]);
}else if($values[0]=='message'){
	$message[0]=trim($values[1]);
}else if(($this->brackets=='both'||$this->brackets=='[')&&preg_match("/txt\([0-9]+\)/", $values[0])){
	$message[$this->_get_index($values[0], '(')] = trim($values[1]);
}else if(($this->brackets=='both'||$this->brackets=='{')&&preg_match("/txt\[[0-9]+\]/", $values[0])){
	$message[$this->_get_index($values[0], '[')] = trim($values[1]);
}

This will allocate values defined in your {mosmap } into appropriate array. Now addresses values are in address array, txt values are in message array and pic values are in pic array. Now we need to build a marker for each one address and place our values over there.

We need to do some alternations to one statement. It's near 1900 line.

if($client_geo == 1){if ($clientgeotype=="local") {
	$code.="\nvar localSearch = new GlocalSearch();";
	$replace = array("\n", "\r", "<br/>", "<br />", "<br>");
	$addr = str_replace($replace, '', $address);
 
	$code.="\nvar address = \"".$addr."\";";
	$code.="\nlocalSearch.setSearchCompleteCallback(null,	function() {
			if (localSearch.results[0]) {
			var resultLat = localSearch.results[0].lat;
			var resultLng = localSearch.results[0].lng;
			var point = new GLatLng(resultLat,resultLng);
			} else ";
 
	if ($latitude !=''&&$longitude!='')
		$code.="var point = new GLatLng( $latitude, $longitude);";
	else
		$code.="var point = new GLatLng( $deflatitude, $deflongitude);";
	} else {
		$code.="var geocoder = new GClientGeocoder();";
		$replace = array("\n", "\r", "<br/>", "<br />", "<br>");
		$addr = str_replace($replace, '', $address);
 
		$code.="var address = \"".$addr."\";";
		$code.="geocoder.getLatLng(address, function(point) {
			    if (!point)";
 
		if ($latitude !=''&&$longitude!='')
			$code.="var point = new GLatLng( $latitude, $longitude);";
		else
			$code.="var point = new GLatLng( $deflatitude, $deflongitude);";
	}
 
} else { //we'll add our code here
	if ($latitude !=''&&$longitude!='')
		$code.="\nvar point = new GLatLng( $latitude, $longitude);";
	else
		$code.="\nvar point = new GLatLng( $deflatitude, $deflongitude);";
}

Delete everything inside else block and paste this code:

$i = 0;
foreach($address as $ind){			
 
	//search for the address
	$coord = $this->get_geo($ind);
	//get directions
	list ($longitude, $latitude, $altitude) = explode(",", $coord);
	$code.="\nvar point = new GLatLng( $latitude, $longitude);";
        $code.="\nvar mess = \"".$message[$i]."\";";
	$code.="\nvar img = \"".$image[$i]."\";";
	$code.="map".$mapnm.".addOverlay(createMarker(point, mess, img));";
	$i++;
}

To see our markers we've to create our own function. I've called it createMarker(), parameters that we past to it are point ( location of our address), message (description ) and img(image for that place). Try to find the line in your plugin file:

  1. $code.="<script type='text/javascript'>//<![CDATA[\n";

Then add following script:

  1. $code.=" function createMarker(point, message, img) {
  2. // Create our tiny marker icon
  3. var SailIcon = new GIcon(G_DEFAULT_ICON);
  4.  
  5. // Set up our GMarkerOptions object
  6. markerOptions = { icon:SailIcon };
  7.  
  8. var marker = new GMarker(point, markerOptions );
  9.  
  10. GEvent.addListener(marker, 'click', function() {
  11. var myHtml = '<img src='+img+
  12. ' style=\'height: 75px;position: relative; float: left\'/>
  13. <div style=\'position: relative; float: left; margin: 0 10px;\'>'+message+ '</div>
  14.  
  15. ';
  16.  
  17. map".$mapnm.".openInfoWindowHtml(point, myHtml);
  18. });
  19. return marker;
  20. }";

Now you can try our upgraded plugin:)

Please be lenient for my spellings and grammar. I'm waiting for your opinions.

How to change Favicon Joomla 1.5

That cosmetic change can be easily made in couple minutes.

First way (simple one) to do that is swapping an existing icon file to one that you chosen. You can find favicon file in:

"YOUR_SITE/templates/YOUR_TEMPLATE/"

Upload your "favicon.ico" file to that directory and overwrite the old icon file.

Second way ( advenced) to do that is editing

"YOUR_SITE//libraries/joomla/document/html/html.php"

In html.php at line 343 you should find code like this:

// Try to find a favicon by checking the template and root folder
$path = $directory . DS;
$dirs = array( $path, JPATH_BASE . DS );
foreach ($dirs as $dir )
{
$icon = $dir . 'favicon.ico';
if (file_exists( $icon ))
{
$path = str_replace( JPATH_BASE . DS, '', $dir );
$path = str_replace( '\\', '/', $path );
$this->addFavicon( JURI::base(true).'/'.$path . 'favicon.ico' );
break;
}
}

Reaplece "favicon.ico" with your file. It can be any type of file for example: icon.jpg, image.gif. Don't forget to upload your new file to the directory:

"YOUR_SITE/templates/YOUR_TEMPLATE/"

That's it:)

WordPress Website Icon

Hello

As first post something useful and easy to do. We're going to change favicon of our blog.

If you already have image you want to use as an icon make sure it is square for example: 128 x 128 px. Files' extension doesn't need to be *.ico, that will works with *.jpg and *.gif as well.

If you don't have your icon you can easily make one on:

http://www.rw-designer.com/online_icon_maker.php.


Upload your favicon file to yours blog root directory. Next you need to edit header.php file of your template. You'll find it in "/wp-content/themes/YOUR_THEME/header.php". Simply put this code  into header.php:

<link rel="shortcut icon" href="YOUR_ICON" />

Save changes and it's done:)