Using multiple Google Maps API keys when using domain aliases

From JReviews Documentation
Jump to: navigation, search

The add-on has a setting for only one API key. If you have alias domains pointed to your main site you will need one key per domain. The following hack will allow you to do that.

  • /components/com_jreviews/jreviews/controllers/my_controller.php
function beforeFilter() {
 
   # Init Access
   if(isset($this->Access)){
      $this->Access->init($this->Config);
   }
 
   # Load a different google maps key for every domain alias
   switch($_SERVER['HTTP_HOST']) {
      case 'www.domain-alias.com':
         $this->Config->{'geomaps.google_key'} = 'Google Maps API Key for the domain alias';
      break;
   }