我正在为Joomla定制HTML模板! 3.7.2,除了点击徽标时的多语言重定向外,一切似乎都能正常工作。
1)我在index.php文件中输入了logo:
<a id="t-logo" href="<?php echo $this->baseurl; ?>/">
<?php echo $doc->getBuffer('modules', 'logo', array('style' => 'none')); ?>
</a>
然后我使用一个模块在该位置分配徽标的图像(以便我的客户可以在将来轻松更改)。
无论如何,我看到如果我从主要语言(IT)切换到EN,然后我点击徽标,而不是重定向到EN主页,它总是将我重定向到IT主页。这只发生在我的模板上(使用默认的Joomla!Protostar测试,我没有看到这个问题)。
这是我的index.php代码:
<?php
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$menu = $app->getMenu();
$doc = JFactory::getDocument();
$user = JFactory::getUser();
... 加载一些CSS和JS ...
// Output as HTML5
$this->setHtml5(true);
// Getting params from template
$params = $app->getTemplate(true)->params;
// Detecting Active Variables
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = $app->get('sitename');
// Aggiunge la classe della pagina
$menu = $app->getMenu()->getActive();
$pageclass = '';
if (is_object($menu))
$pageclass = $menu->params->get('pageclass_sfx');
// fine aggiunge classe della pagina
if($task == "edit" || $layout == "form" )
{
$fullWidth = 1;
}
else
{
$fullWidth = 0;
}
?>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
<jdoc:include type="head" />
<!--[if lt IE 9]><script src="<?php echo JUri::root(true); ?>/media/jui/js/html5.js"></script><![endif]-->
</head>
<body class="<?php echo $pageclass; ?> site <?php echo $option
. ' view-' . $view
. ($layout ? ' layout-' . $layout : ' no-layout')
. ($task ? ' task-' . $task : ' no-task')
. ($itemid ? ' itemid-' . $itemid : '')
. ($params->get('fluidContainer') ? ' fluid' : '');
echo ($this->direction == 'rtl' ? ' rtl' : '');
?>">
<div class="main-wrapper">
<div class="topbar inner-container container">
<div class="l-sec col-xs-6 col-md-9">
<?php if ($this->countModules('shortinfo')) : ?>
<jdoc:include type="modules" name="shortinfo" style="none" />
<?php endif; ?>
</div>
<div class="r-sec col-xs-6 col-md-3">
<?php if ($this->countModules('language')) : ?>
<jdoc:include type="modules" name="language" style="none" />
<?php endif; ?>
</div>
</div>
<!-- Header Section -->
<header id="main-header">
<div class="inner-container container">
<div class="l-sec col-xs-6 col-sm-6 col-md-3">
<a id="t-logo" href="<?php echo $this->baseurl; ?>/">
<?php echo $doc->getBuffer('modules', 'logo', array('style' => 'none')); ?>
</a>
</div>
<?php if ($this->countModules('main-menu')) : ?>
<div class="r-sec col-xs-6 col-sm-6 col-md-9">
<nav id="main-menu" class="navigation" role="navigation">
<jdoc:include type="modules" name="main-menu" style="none" />
</nav>
<div id="main-menu-handle" class="ravis-btn btn-type-2"><i class="fa fa-bars"></i><i class="fa fa-close"></i></div><!-- Mobile Menu handle -->
<?php if ($this->countModules('bookingbutton')) : ?>
<jdoc:include type="modules" name="bookingbutton" style="none" />
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div id="mobile-menu-container"></div>
</header>
<!-- End of Header Section -->
<?php if ($this->countModules('header')) : ?>
<section id="breadcrumb-section" data-bg-img="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/images/header.jpg" style="background-image: url('<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/images/header.jpg');">
<div class="inner-container container">
<div class="ravis-title">
<div class="inner-box">
<div class="title">
<h1 itemprop="headline">
<?php echo $page_title = $doc->getTitle(); ?>
</h1>
</div>
<div class="sub-title"><h2 class="great-vibes"><?php echo htmlspecialchars($images->image_intro_alt); ?></h2></div>
</div>
</div>
<div class="breadcrumb">
<?php
$modules =& JModuleHelper::getModules('breadcrumb');
foreach ($modules as $module)
{
echo JModuleHelper::renderModule($module);
}
?>
</div>
</div>
</section>
<?php endif; ?>
<?php if ($this->countModules('main-slider')) : ?>
<div class="slider-available-sec">
<jdoc:include type="modules" name="main-slider" style="none" />
<?php if ($this->countModules('booking-form')) : ?>
<jdoc:include type="modules" name="booking-form" style="none" />
<?php endif; ?>
</div>
<?php endif; ?>
<jdoc:include type="message" />
<div class="componentarea">
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
$lang = JFactory::getLanguage();
if ($menu->getActive() != $menu->getDefault($lang->getTag())) : ?>
<jdoc:include type="component" />
<?php endif; ?>
</div>
<?php if ($this->countModules('welcome')) : ?>
<jdoc:include type="modules" name="welcome" style="none" />
<?php endif; ?>
<?php if ($this->countModules('luxury-rooms')) : ?>
<jdoc:include type="modules" name="luxury-rooms" style="none" />
<?php endif; ?>
<?php if ($this->countModules('events')) : ?>
<jdoc:include type="modules" name="events" style="none" />
<?php endif; ?>
<?php if ($this->countModules('services')) : ?>
<jdoc:include type="modules" name="services" style="none" />
<?php endif; ?>
<?php if ($this->countModules('tour')) : ?>
<jdoc:include type="modules" name="tour" style="none" />
<?php endif; ?>
<?php if ($this->countModules('gallery')) : ?>
<jdoc:include type="modules" name="gallery" style="none" />
<?php endif; ?>
<?php if ($this->countModules('testimonials')) : ?>
<jdoc:include type="modules" name="testimonials" style="none" />
<?php endif; ?>
<?php if ($this->countModules('pacchetti')) : ?>
<jdoc:include type="modules" name="pacchetti" style="none" />
<?php endif; ?>
<?php if ($this->countModules('richiesta')) : ?>
<jdoc:include type="modules" name="richiesta" style="none" />
<?php endif; ?>
<!--Footer Section-->
<footer id="main-footer">
<div class="inner-container container">
<div class="t-sec clearfix">
<?php if ($this->countModules('footer-1')) : ?>
<jdoc:include type="modules" name="footer-1" style="xhtml" />
<?php endif; ?>
<?php if ($this->countModules('footer-2')) : ?>
<jdoc:include type="modules" name="footer-2" style="xhtml" />
<?php endif; ?>
<?php if ($this->countModules('footer-3')) : ?>
<jdoc:include type="modules" name="footer-3" style="xhtml" />
<?php endif; ?>
<?php if ($this->countModules('footer-4')) : ?>
<jdoc:include type="modules" name="footer-4" style="xhtml" />
<?php endif; ?>
</div>
<?php if ($this->countModules('copyright')) : ?>
<jdoc:include type="modules" name="copyright" style="none" />
<?php endif; ?>
</div>
</footer>
<!--End of Footer Section-->
</div>
</body>
</html>
有任何建议以及如何解决此问题?
提前致谢!
答案 0 :(得分:1)
以下是我用于其中一个模板的一些代码,很容易适应您的情况:
<?php
$app = JFactory::getApplication();
$lang = JFactory::getLanguage();
if ($this->language ==’en-gb’){
echo ‘<a href=”‘ .$this->baseurl .’/en” class=”” title=””>’;
}
else {
echo ‘<a href=”‘ .$this->baseurl .’/fr” class=”” title=””>’;
}
?>
<img class=”logo” src=”/path/images/header/logo.png” alt=””>
<?php
echo “</a>”;
?>