2013-06-21 121 views
2

我正在爲希望在一個joomla實例下擁有多個微型網站和一個主站點的客戶端構建模板。我在Joomla中構建它,因爲這就是我所知道的,所以請不要建議另一個CMS,而且我知道Drupal本身就支持這個!所以這裏是瘦。現在,我的模板從模板參數中查找域名,然後將其與基本URI進行比較,然後設置要在整個模板中使用的變量。因此,代碼看起來像這樣...Joomla基於微型網站的URL的不同默認頁面

//multisite configuration - determines which template params and menu module to display depending on the base URL 
$url = JURI::base(); 
$primary = 'http://'.$this->params->get('site-domain').'/'; 
$sub1= 'http://'.$this->params->get('domain1-domain').'/'; 
$sub2= 'http://'.$this->params->get('domain2-domain').'/'; 
$sub3= 'http://'.$this->params->get('domain3-domain').'/'; 
$sub4= 'http://'.$this->params->get('domain4-domain').'/'; 
$sub5= 'http://'.$this->params->get('domain5-domain').'/'; 
if($url == $primary): 
    $logo = $this->params->get('logo'); 
    $title = $this->params->get('site-title'); 
    $slogan = $this->params->get('site-slogan'); 
    $menu = '<jdoc:include type="modules" name="menu" />'; 
elseif($url == $sub1): 
    $logo = $this->params->get('domain1-logo'); 
    $title = $this->params->get('domain1-title'); 
    $slogan = $this->params->get('domain1-slogan'); 
    $menu = '<jdoc:include type="modules" name="menu-1" />'; 
elseif($url == $sub2): 
    $logo = $this->params->get('domain2-logo'); 
    $title = $this->params->get('domain2-title'); 
    $slogan = $this->params->get('domain2-slogan'); 
    $menu = '<jdoc:include type="modules" name="menu-2" />'; 
elseif($url == $sub3): 
    $logo = $this->params->get('domain3-logo'); 
    $title = $this->params->get('domain3-title'); 
    $slogan = $this->params->get('domain3-slogan'); 
    $menu = '<jdoc:include type="modules" name="menu-3" />'; 
elseif($url == $sub4): 
    $logo = $this->params->get('domain4-logo'); 
    $title = $this->params->get('domain4-title'); 
    $slogan = $this->params->get('domain4-slogan'); 
    $menu = '<jdoc:include type="modules" name="menu-4" />'; 
elseif($url == $sub5): 
    $logo = $this->params->get('domain5-logo'); 
    $title = $this->params->get('domain5-title'); 
    $slogan = $this->params->get('domain5-slogan'); 
    $menu = '<jdoc:include type="modules" name="menu-5" />'; 
endif; 

所以,現在我需要做的是建立,它決定了菜單項ID是默認的菜單項,然後做一個PHP頭重定向模板參數。由於Joomla不支持多個默認值,我需要一個解決方法來生成必要的重定向URL。我想菜單項ID或別名,因爲我不想被限制爲類別或文章類型顯示。不幸的是解決這個問題是我對PHP和Joomla的知識不足的地方。任何幫助都會很棒。

感謝 桑德拉:)

回答

3

你也可以使用像Virtual Domains的擴展,它可以讓你用不同的默認菜單項不同的域相關聯。然後,你可以使用標準的Joomla模板,並以菜單爲基礎進行分配。

+0

真的不是我正在尋找的答案,但謝謝。 –

+1

是的,我意識到這不是您正在尋找的答案,但在模板中實施多域類型解決方案並非最佳選擇。理想情況下,您可以在收到請求後但在路由之前執行此操作。在渲染過程中,您正在嘗試在執行週期的後期執行此操作。類似於我所建議的解決方案將在執行週期中更適當的位置執行此操作,並防止您不必重新發明輪子。您可以使用模板樣式爲每個域的默認菜單項實現模板外觀。 – betweenbrain

相關問題