您可以使用the ServerUrl
view helper。也請檢查this answer here。
$serverUrl = $this->serverUrl(); // output: http://www.siteX.com
然後你可以根據這個變量的值設置一個CSS或其他特定的佈局。例如,你可以使用a php switch statement爲您的視圖中(在layout.html
文件):
鑑於:
switch($serverUrl){
case 'http://www.site1.com':
// logic for site 1
break;
case 'http://www.site2.com':
// logic for site 2
break;
case 'http://www.site3.com':
// logic for site 3
break;
case 'http://www.site4.com':
// logic for site 4
break;
case 'http://www.site5.com':
// logic for site 5
break;
case 'http://www.site6.com':
// logic for site 6
break;
}
或者你也可以在你的控制器根據設置不同的佈局值爲$serverUrl
。如何設置佈局也解釋here in this answer。因此,像:
在控制器:
$serverUrlHelper = $this->getServiceLocator()->get('ViewHelperManager')->get('ServerUrl');
$serverUrl = $serverUrlHelper();
switch($serverUrl){
case 'http://www.site1.com':
$this->layout('layout/layout1');
break;
case 'http://www.site2.com':
$this->layout('layout/layout2');
break;
case 'http://www.site3.com':
$this->layout('layout/layout3');
break;
case 'http://www.site4.com':
$this->layout('layout/layout4');
break;
case 'http://www.site5.com':
$this->layout('layout/layout5');
break;
case 'http://www.site6.com':
$this->layout('layout/layout6');
break;
}
現在我用switch語句,但也有可能像100不同的方式來做到這一點,但我離開了你的創造力。