我正在尝试在我正在构建的模板 index.php 中重定向并获得重定向循环。我错过了什么吗?我正在尝试做的是根据条目 URL 以及某些模板样式重定向默认页面。我的模板代码看起来像这样......
配置文件
<?php
//joomla configuration
JLoader::import('joomla.filesystem.file');
JHtml::_('behavior.framework', true);
JHtml::_('jquery.framework');
$app = JFactory::getApplication();
$config = JFactory::getConfig();
$doc = JFactory::getDocument();
//load template style sheets and scripts
$doc->addStyleSheet($this->baseurl.'/media/jui/css/bootstrap.min.css');
$doc->addStyleSheet($this->baseurl.'/media/jui/css/bootstrap-responsive.min.css');
$doc->addStyleSheet('templates/' . $this->template . '/css/template.css');
$doc->addScript('templates/' . $this->template . '/javascript/template.js');
//sidebar configuration - determines the span classes for the sidebar and main component area
$component = $this->params->get('component-span');
if(!$this->countModules('sidebar')):
$component = 12;
endif;
$sidebar = 12 - $component;
$sidebar_pos = $this->params->get('sidebar-pos');
//navbar inverse
if($this->params->get('navbar-inverse') == 'TRUE'):
$inverse = ' navbar-inverse';
endif;
//multisite configuration - determines which template params and menu module to display depending on the base URL
$domain = $_SERVER["SERVER_NAME"];
$primary = $this->params->get('site-domain');
$sub1= $this->params->get('domain1-domain');
$sub2= $this->params->get('domain2-domain');
$sub3= $this->params->get('domain3-domain');
$sub4= $this->params->get('domain4-domain');
$sub5= $this->params->get('domain5-domain');
$menuid = $app->getMenu();
if($domain == $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($domain == $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" />';
$menuitemid = $this->params->get('domain1-menuid');
$menuitem = $menuid->getItem($menuitemid);
elseif($domain == $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" />';
$itemid = $this->params->get('domain2-menuid');
elseif($domian == $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" />';
$itemid = $this->params->get('domain3-menuid');
elseif($domain == $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" />';
$itemid = $this->params->get('domain4-menuid');
elseif($domain == $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" />';
$itemid = $this->params->get('domain5-menuid');
endif;
?>
索引.php
<?php
defined('_JEXEC') or die;
include($this->baseurl.'templates/'.$this->template.'/includes/config.php');
$default_page = new JURI($menuitem->link);
print($domain.'<br />'.$primary.'<br />'.$default_page);
if ($domain != $primary):
$link = $default_page;
$msg = 'Testing Redirect';
$app->redirect($link, $msg);
endif;
?>
<!DOCTYPE html>
<html>
<head>
<?php $this->setTitle($title.' - '.$this->getTitle()); ?>
<jdoc:include type="head" />
</head>