简体   繁体   中英

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

I have a Joomla landing page where user must login or register, before he can visit the home page.

The thing is that my Landing page and Home page is actually one page but with different template it changes appearence and functionality. When I use Landing page template it becomes a landing page and when I use Home page template it becomes Home page.

So, the question is: How can I change/set the template to a particular page manually in index.php file? For example:

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

Please, assist me.

Igor

I guess your start is OK. Make to more files in your template folders, landing.php and home.php, and call them in index.php:

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

In landing.php you simply display your login-module, and the message-tags:

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

while in home.php, you still probably want to load the login-module, but also menu-modules etc, and the component on the home page:

<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" />

Of course you need to add whatever html-structure you need around the elements. Does this make sense?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM