简体   繁体   中英

Joomla logo multilanguage

I'm customizing an HTML template for Joomla! 3.7.2, everything seems work fine except for multilanguage redirect when click on logo.

1) I inser the logo in my index.php file as:

<a id="t-logo" href="<?php echo $this->baseurl; ?>/">
    <?php echo $doc->getBuffer('modules', 'logo', array('style' => 'none')); ?>
</a>

Then I use a module to assign the image of the logo in that position (so that my Client can change it easily in future).

Anyway I see that if I switch from main language (IT) to EN and then I click the logo, instead of being redirected to the EN homepage, it always redirects me to the IT homepage. This happens only with my template (tested with default Joomla! Protostar and I don't see this problem).

This is my index.php code:

<?php

    defined('_JEXEC') or die;

    $app             = JFactory::getApplication();
    $menu            = $app->getMenu();
    $doc             = JFactory::getDocument();
    $user            = JFactory::getUser();

... loading some CSS and 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>

Any suggestion and how to fix this?

Thanks in advance!

Here's some code I use for one of our templates, it would be easy to adapt this to your situation:

<?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>”;
?>

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