簡體   English   中英

如何在joomla中手動將模板設置為頁面

[英]How can I set the template to a page manually in joomla

我有一個Joomla登陸頁面,用戶必須先登錄或注冊,然后才能訪問主頁。

問題是我的登錄頁面和主頁實際上是一頁,但是使用不同的模板,它會更改外觀和功能。 當我使用登錄頁面模板時,它將成為登錄頁面;當我使用主頁模板時,它將變為主頁。

因此,問題是:如何在index.php文件中手動將模板更改/設置為特定頁面? 例如:

$user = JFactory::getUser();
if ($user->guest)
{
  Set Landing page template
}
else
{
  Set Home page template
}

請幫我。

伊戈爾

我想你的開始還可以。 在模板文件夾Landing.php和home.php中創建更多文件,並在index.php中調用它們:

$user = JFactory::getUser();
if ($user->guest)
{
  require_once('landing.php'); 
}
else
{
  require_once('home.php'); 
}

在landing.php中,您只需顯示您的登錄模塊和消息標簽:

<jdoc:include type="message" />
<jdoc:include type="modules" name="login" style="xhtml" />

在home.php中時,您可能仍想加載登錄模塊,菜單模塊等以及主頁上的組件:

<jdoc:include type="modules" name="login" style="xhtml" />
<jdoc:include type="modules" name="topmenu" style="xhtml" />
<jdoc:include type="modules" name="rightmenu" style="xhtml" />
<jdoc:include type="message" />
<jdoc:include type="component" />

當然,您需要在元素周圍添加所需的任何html結構。 這有意義嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM