开发者

How can I realize that the user is navigating the front page?

I am doing some modifications on mu Joomla template and I want to built a completely different home page (Front page) for the template.

This is my first experience with joomla template modification, so I came up with an idea to place an I开发者_Go百科F statement in the index.php file of the template to see if the user is navigating the front page, so the statement is true and the code generates my own code (my front page) and if the user is navigating other pages the if statement would be false then it will generate the built in template.

but the problem is what would be the "if statement"?

//begining of the code....

if (this is the front page){
    //my template code containing some installed modules
}else {
   //run as normal 
}

OR if I am doing totally wrong job, please laugh at me and give a better idea

Thanks


$option = JRequest::getVar('option', '');
$view   = JRequest::getVar('view', '');
$task   = JRequest::getVar('task', '');

if($option == 'com_content' && $view =='frontpage' && $task=='')
{
   //your template code
}
else
{
   //run as normal 
}


Gaurav's answer is correct only for those cases when the homepage is rendered through com_content. Here's a more general solution:

global $Itemid;

$db =& JFactory::getDBO();
$db->setQuery('SELECT `id` FROM `#__menu` WHERE `home`=1');
$frontpageItemid = $db->loadResult();

if( $Itemid == $frontpageItemid )
{
    //your template code
}
else
{
    //run as normal
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜