Index: modules/uoa-connect-portal/trunk/src/app/claims/linking/linkingGeneric.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/claims/linking/linkingGeneric.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/claims/linking/linkingGeneric.component.ts	(revision 54949)
@@ -15,14 +15,17 @@
       private _router: Router
 
       ) {
-        this.route.queryParams.subscribe(
-          communityId => {
-                this.communityId = communityId['communityId'];
-                 if(!this.communityId && typeof document !== 'undefined'){
-                  this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-                 }
+        this.route.data
+            .subscribe((data: { envSpecific: any }) => {
+              this.route.queryParams.subscribe(
+                communityId => {
+                  this.communityId = communityId['communityId'];
+                  if(!this.communityId){
+                    this.communityId  = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                  }
 
-              });
+                });
+            });
 
       }
 }
Index: modules/uoa-connect-portal/trunk/src/app/htmlPages/htmlPage.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/htmlPages/htmlPage.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/htmlPages/htmlPage.component.ts	(revision 54949)
@@ -26,8 +26,8 @@
          this.route.queryParams.subscribe(
            params => {
                  this.communityId = params['communityId'];
-                  if(!this.communityId && typeof document !== 'undefined'){
-                   this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
+                 if(!this.communityId){
+                    this.communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
                   }
                   if(!this.communityId){
                   this.communityId = this.properties.adminToolsCommunity;
Index: modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/utils/subscribe/invite/invite.component.ts	(revision 54949)
@@ -82,7 +82,7 @@
             communityId => {
                   this.communityId = communityId['communityId'];
                   if(!this.communityId && typeof document !== 'undefined'){
-                    this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
+                    this.communityId  = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
                   }
                   this.communityIdParam = (this.properties.environment !="development" )?{}:{communityId:this.communityId};
                   if (this.communityId != null && this.communityId != '') {
Index: modules/uoa-connect-portal/trunk/src/app/community/community.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/community/community.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/community/community.component.ts	(revision 54949)
@@ -41,7 +41,7 @@
   public contentProviderTotal = null;
   public organizationTotal = null;
 
-  params: any;
+  params: any ={};
   properties:EnvProperties;
 
   public publicationResults = null;
@@ -98,7 +98,9 @@
                this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
                  community => {
                       this.community = community;
-                      this.params = {communityId: community.communityId};
+                      if(this.properties.environment == "development"){
+                        this.params = {communityId: community.communityId};
+                      }
                       this._meta.updateTag({content:community.description},"name='description'");
                       this._meta.updateTag({content:community.description},"property='og:description'");
                       this._meta.updateTag({content:community.title},"property='og:title'");
Index: modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositDatasetsResult.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositDatasetsResult.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositDatasetsResult.component.ts	(revision 54949)
@@ -39,8 +39,8 @@
           this.route.queryParams.subscribe(params => {
              var communityId = params['communityId'];
              if(!communityId){
-              communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-             }
+                communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
+              }
              this.piwikSiteId = PiwikHelper.siteIDs[communityId];
 
              if(communityId) {
Index: modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositBySubjectResult.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositBySubjectResult.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositBySubjectResult.component.ts	(revision 54949)
@@ -38,8 +38,8 @@
           this.route.queryParams.subscribe(params => {
              var communityId = params['communityId'];
              if(!communityId){
-              communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-             }
+                communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
+              }
              this.piwikSiteId = PiwikHelper.siteIDs[communityId];
 
              if(communityId) {
Index: modules/uoa-connect-portal/trunk/src/app/deposit/publications/depositPublications.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/deposit/publications/depositPublications.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/deposit/publications/depositPublications.component.ts	(revision 54949)
@@ -29,8 +29,6 @@
   constructor ( private  route: ActivatedRoute,
                 private _ΖenodoCommunitieService: ZenodoCommunitiesService,
                 private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService ) {
-    //var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    //this.piwikSiteId = PiwikHelper.siteIDs[communityId];
     this.fetchZenodoInformation = new FetchZenodoInformation(this._ΖenodoCommunitieService, this._searchZenodoCommunitiesService);
   }
 
@@ -42,8 +40,8 @@
           this.route.queryParams.subscribe(params => {
              var communityId = params['communityId'];
              if(!communityId){
-              communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-             }
+                communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
+              }
              this.piwikSiteId = PiwikHelper.siteIDs[communityId];
 
              if(communityId) {
Index: modules/uoa-connect-portal/trunk/src/app/communitywrapper/communityWrapper.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/communitywrapper/communityWrapper.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/communitywrapper/communityWrapper.component.ts	(revision 54949)
@@ -21,19 +21,23 @@
       private _router: Router
 
       ) {
-        this.route.queryParams.subscribe(
-          communityId => {
-                this.communityId = communityId['communityId'];
-                 if(!this.communityId && typeof document !== 'undefined'){
-                  this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-                 }
-                 if(this.communityId){
-                   this.dashboard = true;
-                 }else{
-                   this.dashboard = false;
-                 }
-              });
+        this.route.data
+            .subscribe((data: { envSpecific: any }) => {
+              this.route.queryParams.subscribe(
+                communityId => {
+                  this.communityId = communityId['communityId'];
+                  if(!this.communityId){
+                    this.communityId  = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                  }
+                  if(this.communityId){
+                    this.dashboard = true;
+                  }else{
+                    this.dashboard = false;
+                  }
 
+                });
+            });
+      
       }
 
   public ngOnInit() {
Index: modules/uoa-connect-portal/trunk/src/app/claims/directLinking/directLinking.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/claims/directLinking/directLinking.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/claims/directLinking/directLinking.component.ts	(revision 54949)
@@ -14,14 +14,17 @@
       private _router: Router
 
       ) {
-        this.route.queryParams.subscribe(
-          communityId => {
-                this.communityId = communityId['communityId'];
-                 if(!this.communityId && typeof document !== 'undefined'){
-                  this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-                 }
+        this.route.data
+            .subscribe((data: { envSpecific: any }) => {
+              this.route.queryParams.subscribe(
+                communityId => {
+                  this.communityId = communityId['communityId'];
+                  if(!this.communityId){
+                    this.communityId  = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                  }
 
-              });
+                });
+            });
 
       }
 }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/find/search.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/find/search.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/find/search.component.ts	(revision 54949)
@@ -15,18 +15,24 @@
   constructor ( private  route: ActivatedRoute) {
   }
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    if(communityId){
-      this.connectCommunityId = communityId
-      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-    }else{
-      this.route.queryParams.subscribe(data => {
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-          this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-        }
-      });
-    }
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+                if(communityId){
+                  this.connectCommunityId = communityId
+                }else{
+                  this.route.queryParams.subscribe(data => {
+
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                    }
+                  });
+         }
+    });
   }
 
 
Index: modules/uoa-connect-portal/trunk/deploy/prepareDeploy.sh
===================================================================
--- modules/uoa-connect-portal/trunk/deploy/prepareDeploy.sh	(revision 54948)
+++ modules/uoa-connect-portal/trunk/deploy/prepareDeploy.sh	(revision 54949)
@@ -8,17 +8,11 @@
 # cp beta-properties.json ../src/assets/env-properties.json;
 
 ## uncommect from here-->
-# echo -n 'Check properties service to have the url for the deployment environment!!';
-# echo -n "Press key:";
-# read -n1 ans
-# echo -n "Pressed";
-# pico ../src/app/openaireLibrary/utils/properties/environment-specific.service.ts;
 # rm -rf ../src/assets/common-assets/.svn/;
 # rm -rf ../src/app/openaireLibrary/.svn/;
 # cd ..; npm run build:dynamic; cd deploy;
-# rm -rf ../src ../node_modules  ../.idea/ ../installOpenaireLib.sh;
+# rm -rf ../src ../node_modules  ../.idea/ ../installOpenaireLib.sh; cd ../; rm -rf deploy;
 # echo 'Now copy to the server!'
-#echo 'remove this deploy folder'
 
 ##<-- to here
 
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchOrps.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchOrps.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchOrps.component.ts	(revision 54949)
@@ -17,18 +17,24 @@
   piwikSiteId = null;
   constructor ( private  route: ActivatedRoute) {
   }
+
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
-    if(communityId){
-      this.connectCommunityId = communityId
-    }else{
-      this.route.queryParams.subscribe(data => {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
 
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-        }
-      });
-    }
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+                if(communityId){
+                  this.connectCommunityId = communityId
+                }else{
+                  this.route.queryParams.subscribe(data => {
+
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                    }
+                  });
+         }
+    });
   }
 }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchDatasets.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchDatasets.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchDatasets.component.ts	(revision 54949)
@@ -20,17 +20,23 @@
   constructor ( private  route: ActivatedRoute) {
   }
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
-    if(communityId){
-      this.connectCommunityId = communityId
-    }else{
-      this.route.queryParams.subscribe(data => {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
 
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-        }
-      });
-    }
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+                if(communityId){
+                  this.connectCommunityId = communityId
+                }else{
+                  this.route.queryParams.subscribe(data => {
+
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                    }
+                  });
+         }
+    });
   }
 }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchSoftware.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchSoftware.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchSoftware.component.ts	(revision 54949)
@@ -18,17 +18,23 @@
   constructor ( private  route: ActivatedRoute) {
   }
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
-    if(communityId){
-      this.connectCommunityId = communityId
-    }else{
-      this.route.queryParams.subscribe(data => {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
 
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-        }
-      });
-    }
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+                if(communityId){
+                  this.connectCommunityId = communityId
+                }else{
+                  this.route.queryParams.subscribe(data => {
+
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                    }
+                  });
+         }
+    });
   }
 }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchPublications.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchPublications.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/advanced/advancedSearchPublications.component.ts	(revision 54949)
@@ -18,17 +18,23 @@
   constructor ( private  route: ActivatedRoute) {
   }
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
-    if(communityId){
-      this.connectCommunityId = communityId
-    }else{
-      this.route.queryParams.subscribe(data => {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
 
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-        }
-      });
-    }
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+                if(communityId){
+                  this.connectCommunityId = communityId
+                }else{
+                  this.route.queryParams.subscribe(data => {
+
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                    }
+                  });
+         }
+    });
   }
 }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchDataproviders.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchDataproviders.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchDataproviders.component.ts	(revision 54949)
@@ -57,8 +57,7 @@
     this.errorCodes = new ErrorCodes();
     this.errorMessages = new ErrorMessagesComponent();
     this.searchUtils.status = this.errorCodes.LOADING;
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+
   }
 
   public ngOnInit() {
@@ -69,9 +68,10 @@
     //this.searchPage.refineFields = this.refineFields;
     this.sub =  this.route.queryParams.subscribe(params => {
       this.communityId = params['communityId'];
-      if(!this.communityId && typeof document !== 'undefined'){
-        this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
+      if(!this.communityId){
+        this.communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
       }
+      this.piwikSiteId = PiwikHelper.siteIDs[this.communityId];
       this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
       //this.filters = this.createFilters();
       //this.searchPage.getParametersFromUrl(params);
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchDatasets.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchDatasets.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchDatasets.component.ts	(revision 54949)
@@ -21,17 +21,24 @@
   constructor ( private  route: ActivatedRoute) {
   }
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    if(communityId){
-      this.connectCommunityId = communityId
-      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-    }else{
-      this.route.queryParams.subscribe(data => {
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-          this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-        }
-      });
-    }
+
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);               
+                if(communityId){
+                  this.connectCommunityId = communityId
+                  this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                }else{
+                  this.route.queryParams.subscribe(data => {
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                    }
+                  });
+                }
+
+    });
+
   }
   }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchOrps.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchOrps.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchOrps.component.ts	(revision 54949)
@@ -23,17 +23,24 @@
   constructor ( private  route: ActivatedRoute) {
   }
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    if(communityId){
-      this.connectCommunityId = communityId
-      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-    }else{
-      this.route.queryParams.subscribe(data => {
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-          this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-        }
-      });
-    }
+
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                if(communityId){
+                  this.connectCommunityId = communityId
+                  this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                }else{
+                  this.route.queryParams.subscribe(data => {
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                    }
+                  });
+                }
+
+    });
+
   }
 }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchOrganizations.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchOrganizations.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchOrganizations.component.ts	(revision 54949)
@@ -1,4 +1,6 @@
 import {Component, Input} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
+
 import {PiwikHelper} from '../../utils/piwikHelper';
 import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
 
@@ -14,9 +16,26 @@
 })
 export class OpenaireSearchOrganizationsComponent {
   piwikSiteId = null;
-  constructor (  ) {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+  constructor (private  route: ActivatedRoute  ) {
   }
+  ngOnInit() {
 
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                if(communityId){
+                  this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+                }else{
+                  this.route.queryParams.subscribe(data => {
+                    if(data['communityId'] && data['communityId']!=""){
+                      communityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+                    }
+                  });
+                }
+
+    });
+
+  }
 }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchProjects.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchProjects.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchProjects.component.ts	(revision 54949)
@@ -57,8 +57,6 @@
     this.errorCodes = new ErrorCodes();
     this.errorMessages = new ErrorMessagesComponent();
     this.searchUtils.status = this.errorCodes.LOADING;
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
   }
 
   public ngOnInit() {
@@ -70,8 +68,9 @@
     this.sub =  this.route.queryParams.subscribe(params => {
       this.communityId = params['communityId'];
       if(!this.communityId && typeof document !== 'undefined'){
-        this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
+        this.communityId  =  ConnectHelper.getCommunityFromDomain(this.properties.domain);
       }
+      this.piwikSiteId = PiwikHelper.siteIDs[this.communityId];
       this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
       //this.filters = this.createFilters();
       //this.searchPage.getParametersFromUrl(params);
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchSoftware.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchSoftware.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchSoftware.component.ts	(revision 54949)
@@ -20,18 +20,26 @@
   piwikSiteId = null;
   constructor ( private  route: ActivatedRoute) {
   }
+
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    if(communityId){
-      this.connectCommunityId = communityId
-      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-    }else{
-      this.route.queryParams.subscribe(data => {
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-          this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-        }
-      });
-    }
+
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                if(communityId){
+                  this.connectCommunityId = communityId
+                  this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                }else{
+                  this.route.queryParams.subscribe(data => {
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                    }
+                  });
+                }
+
+    });
+
   }
 }
Index: modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchPublications.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchPublications.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/searchPages/simple/searchPublications.component.ts	(revision 54949)
@@ -23,17 +23,24 @@
   constructor ( private  route: ActivatedRoute) {
   }
   ngOnInit() {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    if(communityId){
-      this.connectCommunityId = communityId
-      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-    }else{
-      this.route.queryParams.subscribe(data => {
-        if(data['communityId'] && data['communityId']!=""){
-          this.connectCommunityId = data['communityId'];
-          this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
-        }
-      });
-    }
+
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                if(communityId){
+                  this.connectCommunityId = communityId
+                  this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                }else{
+                  this.route.queryParams.subscribe(data => {
+                    if(data['communityId'] && data['communityId']!=""){
+                      this.connectCommunityId = data['communityId'];
+                      this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
+                    }
+                  });
+                }
+
+    });
+
   }
 }
Index: modules/uoa-connect-portal/trunk/src/app/statistics/statistics.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/statistics/statistics.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/statistics/statistics.component.ts	(revision 54949)
@@ -97,8 +97,8 @@
           this.route.queryParams.subscribe(
             communityId => {
                   this.communityId = communityId['communityId'];
-                  if(!this.communityId && typeof document !== 'undefined'){
-                    this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
+                  if(!this.communityId){
+                    this.communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
                   }
                   if(this.currentMode == "showInMonitor" && this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
                     this.piwiksub = this._piwikService.trackView(this.properties, "Monitor "+ this.communityId, PiwikHelper.siteIDs[this.communityId]).subscribe();
Index: modules/uoa-connect-portal/trunk/src/app/landingPages/orp/orp.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/landingPages/orp/orp.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/landingPages/orp/orp.component.ts	(revision 54949)
@@ -1,4 +1,5 @@
 import {Component, ViewChild, ElementRef} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
 import {PiwikHelper}                      from '../../utils/piwikHelper';
 import {ConnectHelper}                    from '../../openaireLibrary/connect/connectHelper';
 
@@ -9,11 +10,16 @@
 
 export class OpenaireOrpComponent {
     piwikSiteId = null;
-    constructor (  ) {
-        var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-        this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+    constructor (private route: ActivatedRoute  ) {
+      this.route.data
+          .subscribe((data: { envSpecific: any }) => {
+
+                  var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                  this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+          });
     }
 
+
     ngOnInit() {
     }
 
Index: modules/uoa-connect-portal/trunk/src/app/landingPages/dataProvider/dataProvider.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/landingPages/dataProvider/dataProvider.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/landingPages/dataProvider/dataProvider.component.ts	(revision 54949)
@@ -1,4 +1,5 @@
 import {Component, ViewChild, ElementRef} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
 import {PiwikHelper} from '../../utils/piwikHelper';
 import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
 
@@ -8,9 +9,13 @@
  })
 export class OpenaireDataProviderComponent{
   piwikSiteId = null;
-  constructor (  ) {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+  constructor (private route: ActivatedRoute  ) {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+        });
   }
 
 ngOnInit() {
Index: modules/uoa-connect-portal/trunk/src/app/landingPages/organization/organization.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/landingPages/organization/organization.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/landingPages/organization/organization.component.ts	(revision 54949)
@@ -1,4 +1,5 @@
 import {Component, ViewChild, ElementRef} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
 import {PiwikHelper} from '../../utils/piwikHelper';
 import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
 @Component({
@@ -7,11 +8,16 @@
  })
 export class OpenaireOrganizationComponent{
   piwikSiteId = null;
-  constructor (  ) {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+  constructor (private route: ActivatedRoute  ) {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+        });
   }
 
+
   ngOnInit() {
 }
 
Index: modules/uoa-connect-portal/trunk/src/app/landingPages/dataset/dataset.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/landingPages/dataset/dataset.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/landingPages/dataset/dataset.component.ts	(revision 54949)
@@ -1,4 +1,5 @@
 import {Component, ViewChild, ElementRef} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
 import {PiwikHelper} from '../../utils/piwikHelper';
 import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
 @Component({
@@ -7,9 +8,13 @@
  })
 export class OpenaireDatasetComponent{
   piwikSiteId = null;
-  constructor (  ) {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+  constructor (private route: ActivatedRoute  ) {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+        });
   }
 
   ngOnInit() {
Index: modules/uoa-connect-portal/trunk/src/app/landingPages/project/project.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/landingPages/project/project.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/landingPages/project/project.component.ts	(revision 54949)
@@ -1,4 +1,5 @@
 import {Component, ViewChild, ElementRef} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
 import {PiwikHelper} from '../../utils/piwikHelper';
 import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
 @Component({
@@ -7,9 +8,13 @@
  })
 export class OpenaireProjectComponent{
   piwikSiteId = null;
-  constructor (  ) {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+  constructor (private route: ActivatedRoute  ) {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+        });
   }
 
   ngOnInit() {
Index: modules/uoa-connect-portal/trunk/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts	(revision 54949)
@@ -1,4 +1,5 @@
 import {Component, ViewChild, ElementRef} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
 import {PiwikHelper} from '../../utils/piwikHelper';
 import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
 @Component({
@@ -7,11 +8,16 @@
  })
 export class OpenaireHtmlProjectReportComponent{
   piwikSiteId = null;
-  constructor (  ) {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+  constructor (private route: ActivatedRoute  ) {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+        });
   }
 
+
   ngOnInit() {
 }
 
Index: modules/uoa-connect-portal/trunk/src/app/landingPages/publication/publication.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/landingPages/publication/publication.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/landingPages/publication/publication.component.ts	(revision 54949)
@@ -1,4 +1,5 @@
 import {Component, ViewChild, ElementRef} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
 import {PiwikHelper} from '../../utils/piwikHelper';
 import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
 @Component({
@@ -7,11 +8,16 @@
  })
 export class OpenairePublicationComponent{
   piwikSiteId = null;
-  constructor (  ) {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+  constructor (private route: ActivatedRoute  ) {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+        });
   }
 
+
   ngOnInit() {
 }
 
Index: modules/uoa-connect-portal/trunk/src/app/landingPages/software/software.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/landingPages/software/software.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/landingPages/software/software.component.ts	(revision 54949)
@@ -1,4 +1,5 @@
 import {Component, ViewChild, ElementRef} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
 import {PiwikHelper} from '../../utils/piwikHelper';
 import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
 @Component({
@@ -7,11 +8,16 @@
  })
 export class OpenaireSoftwareComponent{
   piwikSiteId = null;
-  constructor (  ) {
-    var communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-    this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+  constructor (private route: ActivatedRoute  ) {
+    this.route.data
+        .subscribe((data: { envSpecific: any }) => {
+
+                var communityId =  ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
+                this.piwikSiteId = PiwikHelper.siteIDs[communityId];
+        });
   }
 
+
   ngOnInit() {
 }
 
Index: modules/uoa-connect-portal/trunk/src/app/communities/communities.component.html
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/communities/communities.component.html	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/communities/communities.component.html	(revision 54949)
@@ -236,7 +236,7 @@
               Explore all OA research results. Link all your research. Build your profile
             </div>
             <p>
-              <a target="_blank" href="https://explore.openaire.eu" class="el-link uk-button uk-button-default">
+              <a target="_blank" [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'explore.openaire.eu'" class="el-link uk-button uk-button-default">
                 OpenAIRE.EXPLORE
               </a>
             </p>
@@ -251,7 +251,7 @@
               Join OpenAIRE, use our tools and make your content more visible around the world.
             </div>
             <p>
-              <a target="_blank" href="https://provide.openaire.eu" class="el-link uk-button uk-button-default">
+              <a target="_blank" [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.':'')+'provide.openaire.eu'" class="el-link uk-button uk-button-default">
                 OpenAIRE.PROVIDE
               </a>
             </p>
@@ -281,7 +281,7 @@
               Use our monitoring services and easily track all relevant research results.
             </div>
             <p>
-              <a target="_blank" href="https://monitor.openaire.eu" class="el-link uk-button uk-button-default">
+              <a target="_blank" [href]="'https://'+(properties.environment =='beta' || properties.environment =='development'?'beta.openaire.eu/moniotr':'monitor.openaire.eu')" class="el-link uk-button uk-button-default">
                 OpenAIRE.MONITOR
               </a>
             </p>
Index: modules/uoa-connect-portal/trunk/src/app/app.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/app.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/app.component.ts	(revision 54949)
@@ -1,4 +1,4 @@
-import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
+import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation, Injector } from '@angular/core';
 import {Observable}       from 'rxjs/Observable';
 import {ActivatedRoute} from '@angular/router';
 
@@ -55,21 +55,18 @@
   showMenu:boolean = false;
   communities = null;
   //  community: {id:string, name:string, logoUrl:string};
-   constructor(  private  route: ActivatedRoute, private propertiesService:EnvironmentSpecificService, private _communitiesService:CommunitiesService ) {
+   constructor(  private  route: ActivatedRoute, private propertiesService:EnvironmentSpecificService, private _communitiesService:CommunitiesService, private injector: Injector) {
+
    }
 
    ngOnInit() {
      this.propertiesService.loadEnvironment()
              .then(es => {
-                 this.propertiesService.setEnvProperties(es);
                  this.properties = this.propertiesService.envSpecific;
-
      this.route.queryParams.subscribe(data => {
        var community = null;
        this.community = null;
        this.showMenu = false;
-       // var test:MenuItem = new MenuItem("monitor","Monitor","","/monitor",false,[],["/monitor"],this.properties.environment!="development"?{}:{communityId:community.communityId});
-       // test.
 
        this._communitiesService.getCommunities(this.properties, this.properties.communitiesAPI).subscribe (
          communities => {
@@ -76,7 +73,7 @@
 
                 for(var com of communities){
                    if((data['communityId'] && data['communityId']!="" &&  com.communityId  == data['communityId'])
-                   || (typeof document !== 'undefined' && (ConnectHelper.getCommunityFromDomain(document.location.hostname) ==  com.communityId )  )){
+                   || (ConnectHelper.getCommunityFromDomain(this.properties.domain) ==  com.communityId )  ){
                     community = com;
                     this.community = {id: community.communityId, name: (community.shortTitle)?community.shortTitle:community.title, logoUrl:community.logoUrl};
                     this.menuItems= [
Index: modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositDatasets.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositDatasets.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/deposit/datasets/depositDatasets.component.ts	(revision 54949)
@@ -40,8 +40,8 @@
           this.route.queryParams.subscribe(params => {
              var communityId = params['communityId'];
              if(!communityId){
-              communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-             }
+                communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
+              }
              this.piwikSiteId = PiwikHelper.siteIDs[communityId];
 
              if(communityId) {
Index: modules/uoa-connect-portal/trunk/src/app/deposit/publications/depositPublicationsResult.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/deposit/publications/depositPublicationsResult.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/deposit/publications/depositPublicationsResult.component.ts	(revision 54949)
@@ -39,8 +39,8 @@
           this.route.queryParams.subscribe(params => {
              var communityId = params['communityId'];
              if(!communityId){
-              communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
-             }
+                communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
+              }
              this.piwikSiteId = PiwikHelper.siteIDs[communityId];
 
              if(communityId) {
Index: modules/uoa-connect-portal/trunk/src/app/deposit/zenodo/shareInZenodo.component.ts
===================================================================
--- modules/uoa-connect-portal/trunk/src/app/deposit/zenodo/shareInZenodo.component.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/src/app/deposit/zenodo/shareInZenodo.component.ts	(revision 54949)
@@ -51,8 +51,8 @@
          this.properties = data.envSpecific;
           this.route.queryParams.subscribe(params => {
             this.communityId = params['communityId'];
-             if(!this.communityId && typeof document !== 'undefined'){
-              this.communityId  = ConnectHelper.getCommunityFromDomain(document.location.hostname);
+            if(!this.communityId){
+               this.communityId  = ConnectHelper.getCommunityFromDomain(this.properties.domain);
              }
 
             if(this.communityId) {
Index: modules/uoa-connect-portal/trunk/server.ts
===================================================================
--- modules/uoa-connect-portal/trunk/server.ts	(revision 54948)
+++ modules/uoa-connect-portal/trunk/server.ts	(revision 54949)
@@ -28,13 +28,25 @@
 import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
 
 // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
-app.engine('html', ngExpressEngine({
-  bootstrap: AppServerModuleNgFactory,
-  providers: [
-    provideModuleMap(LAZY_MODULE_MAP)
-  ]
-}));
+// app.engine('html', ngExpressEngine({
+//   bootstrap: AppServerModuleNgFactory,
+//   providers: [
+//      { provide: 'request', useFactory: () => options.req, deps: [] },
+//     provideModuleMap(LAZY_MODULE_MAP)
+//   ]
+// }));
 
+app.engine('html', (_, options, callback) => {
+    let engine = ngExpressEngine({
+        bootstrap: AppServerModuleNgFactory,
+        providers: [
+            { provide: 'request', useFactory: () => options.req, deps: [] },
+            provideModuleMap(LAZY_MODULE_MAP)
+        ]
+    });
+    engine(_, options, callback);
+});
+
 app.set('view engine', 'html');
 app.set('views', join(DIST_FOLDER, 'browser'));
 
