Bug: Logo doesnt go to homepage after update

GK User
Tue Nov 22, 2016 9:15 am
Dear Sir/Madame,

I am facing a problem with my logo which reacts strangely after the update.

Let me just describe what happens. First of all I created a 2 language website, greek and english, with main language greek. Here it is:
http://www.watermill.gr/

So what happens is:
If you are on the homepage in Greek language (http://www.watermill.gr/el) and you navigate to menu items and then press the logo icon everything works fine.
When you switch to the English language ((http://www.watermill.gr/en) and you navigate to menu items and then press the logo icon everything works fine.
But when you back again to the Greek version (http://www.watermill.gr/el) and you navigate to menu items and then press the logo icon you are redirected to the English version (http://www.watermill.gr/en) of the site.

It seems that for some reason it caches the en language.
I have done some customization to the theme and so I thought that was the problem. What I did, in order to troubleshoot, was to load the latest version of your theme, clean as you provide it to us - and I deleted all the old customized files - , but the problem still occurred.

I am not using any browser caching nor compression.

Now online is the customized version.

I would very much appreciate your help.

Thank you in advance,
Dimitris Belegris
User avatar
Fresh Boarder

GK User
Tue Nov 22, 2016 9:48 am
UPDATE:

I updated both "logo.php" and "logo_small.php" to this and it works:

logo.php

Code: Select all
<?php

// No direct access.
defined('_JEXEC') or die;
$logo_image = $this->API->get('logo_image', '');

if(($logo_image == '') || ($this->API->get('logo_type', '') == 'css')) {
     $logo_image = $this->API->URLtemplate() . '/images/logo.png';
} else {
     $logo_image = $this->API->URLbase() . $logo_image;
}

$logo_text = $this->API->get('logo_text', '');
$logo_slogan = $this->API->get('logo_slogan', '');

?>
<?php
  $lang = JFactory::getLanguage();
if ($lang->getTag() == 'en-GB'): ?>
<?php if ($this->API->get('logo_type', 'image')!=='none'): ?>
     <?php if($this->API->get('logo_type', 'image') == 'css') : ?>
     <a href="/en" id="gkLogo" class="cssLogo"><?php echo $this->API->get('logo_text', ''); ?></a>
     <?php elseif($this->API->get('logo_type', 'image')=='text') : ?>
     <a href="/en" id="gkLogo" class="text">
      <span><?php echo $this->API->get('logo_text', ''); ?></span>
       
        <?php if($this->API->get('logo_slogan', '') != '') : ?>
        <small class="gkLogoSlogan"><?php echo $this->API->get('logo_slogan', ''); ?></small>
        <?php endif; ?>
     </a>
     <?php elseif($this->API->get('logo_type', 'image')=='image') : ?>
    <a href="/en" id="gkLogo">
        <img src="<?php echo $logo_image; ?>" alt="<?php echo $this->API->getPageName(); ?>" />
     </a>
     <?php endif; ?>
<?php endif; ?>
<?php elseif ($lang->getTag() == 'el-GR'): ?>
<?php if ($this->API->get('logo_type', 'image')!=='none'): ?>
     <?php if($this->API->get('logo_type', 'image') == 'css') : ?>
     <a href="/el" id="gkLogo" class="cssLogo"><?php echo $this->API->get('logo_text', ''); ?></a>
     <?php elseif($this->API->get('logo_type', 'image')=='text') : ?>
     <a href="/el" id="gkLogo" class="text">
      <span><?php echo $this->API->get('logo_text', ''); ?></span>
       
        <?php if($this->API->get('logo_slogan', '') != '') : ?>
        <small class="gkLogoSlogan"><?php echo $this->API->get('logo_slogan', ''); ?></small>
        <?php endif; ?>
     </a>
     <?php elseif($this->API->get('logo_type', 'image')=='image') : ?>
    <a href="/el" id="gkLogo">
        <img src="<?php echo $logo_image; ?>" alt="<?php echo $this->API->getPageName(); ?>" />
     </a>
     <?php endif; ?>
<?php endif; ?>
<?php endif; ?>


logo_small.php

Code: Select all
<?php

// No direct access.
defined('_JEXEC') or die;
$logo_image = $this->API->get('small_logo_image', '');

if(($logo_image == '') || ($this->API->get('logo_type', '') == 'css')) {
     $logo_image = $this->API->URLtemplate() . '/images/logo-small.png';
} else {
     $logo_image = $this->API->URLbase() . $logo_image;
}

$logo_text = $this->API->get('logo_text', '');
$logo_slogan = $this->API->get('logo_slogan', '');

?>
<?php
  $lang = JFactory::getLanguage();
if ($lang->getTag() == 'en-GB'): ?>
<?php if ($this->API->get('logo_type', 'image')!=='none'): ?>
     <?php if($this->API->get('logo_type', 'image') == 'css') : ?>
     <a href="/en" id="gkLogoSmall" class="cssLogo"><?php echo $this->API->get('logo_text', ''); ?></a>
     <?php elseif($this->API->get('logo_type', 'image')=='text') : ?>
     <a href="/en" id="gkLogoSmall" class="text">
      <span><?php echo $this->API->get('logo_text', ''); ?></span>
       
        <?php if($this->API->get('logo_slogan', '') != '') : ?>
        <small class="gkLogoSlogan"><?php echo $this->API->get('logo_slogan', ''); ?></small>
        <?php endif; ?>
     </a>
     <?php elseif($this->API->get('logo_type', 'image')=='image') : ?>
    <a href="/en" id="gkLogoSmall">
        <img src="<?php echo $logo_image; ?>" alt="<?php echo $this->API->getPageName(); ?>" />
     </a>
     <?php endif; ?>
<?php endif; ?>
<?php elseif ($lang->getTag() == 'el-GR'): ?>
<?php if ($this->API->get('logo_type', 'image')!=='none'): ?>
     <?php if($this->API->get('logo_type', 'image') == 'css') : ?>
     <a href="/el" id="gkLogoSmall" class="cssLogo"><?php echo $this->API->get('logo_text', ''); ?></a>
     <?php elseif($this->API->get('logo_type', 'image')=='text') : ?>
     <a href="/el" id="gkLogoSmall" class="text">
      <span><?php echo $this->API->get('logo_text', ''); ?></span>
       
        <?php if($this->API->get('logo_slogan', '') != '') : ?>
        <small class="gkLogoSlogan"><?php echo $this->API->get('logo_slogan', ''); ?></small>
        <?php endif; ?>
     </a>
     <?php elseif($this->API->get('logo_type', 'image')=='image') : ?>
    <a href="/el" id="gkLogoSmall">
        <img src="<?php echo $logo_image; ?>" alt="<?php echo $this->API->getPageName(); ?>" />
     </a>
     <?php endif; ?>
<?php endif; ?>
<?php endif; ?>


The thing is, that what I did is not recommended as I manually inserted my language(and if more languages added I must insert them manually).

What I did was actually replacing the <?php echo JURI::root(); ?> with the language suffix. I don't know if it is a joomla issue with JURI::root or a theme issue but I am just reporting the bug.

Can you also check it out and recommend a more proper solution??

Thank you in advance.
User avatar
Fresh Boarder

teitbite
Sun Nov 27, 2016 10:18 am
Hi

I'm afraid I do not know either. There were no reports of such behaviour yet, so I would need to have an access to a server where this is happening to run some tests. If You want me to look into it, please send me an access to FTP, joomla panel and url to Your site.
User avatar
Moderator

teitbite
Sun Dec 04, 2016 11:13 am
Hi

Sorry for late reply. I've spend couple of hours in a code of Your site, also consulted with programmers and this problem absolutely makes no sense ;/ The plugin responsible for the language selection simply does not react on frontpage. So I believe it may be connected woth some specific server settings, because there is no more reports of same issue currently and I cannot reproduce it on none of my servers. Because of that I would advice to use the fix You've came up with sine I cannot get to the bottom of this problem to tell why is it like that and fix it. Sorry.
User avatar
Moderator

GK User
Fri Dec 09, 2016 9:37 am
Hello and sorry for my late reply as well,

I think its not a server issue because it does not react the same way with other Joomla websites I have set up. Its a strange issue (I have never came up with it myself) and maybe its a Joomla one (after the update). Anyway, I need you help making the same override in the Homepage menu item.

Can you please tell me which .php file I should change??
Thank you in advance.
User avatar
Fresh Boarder

teitbite
Sun Dec 11, 2016 4:31 pm
Hi

I'm not saying it's a server issue, just something that appears with a specific configuration.

Let's use a script added to file /layout/blocks/head.php

Code: Select all
<script type="text/javascript">(function($) {$(document).ready(function() {
    var varhref = '/en';
    if( $('html').attr('lang') == 'el-gr' ) {
        varhref = '/el';
    }

    $('#gkLogo, #menu640').attr('href', varhref);
});})(jQuery)</script>
User avatar
Moderator

GK User
Wed Dec 28, 2016 11:32 am
Thank you very much for your help and sorry for my late reply.

This code works like a charm. It does the job perfectly. If I want to add another language to the site should I just add a second "if"??
User avatar
Fresh Boarder

teitbite
Mon Jan 02, 2017 3:23 pm
Hi

Yes. Another "if" below or an "elseif" if You want to reuse same condition. Example:

Code: Select all
    if( $('html').attr('lang') == 'el-gr' ) {
        varhref = '/el';
    } elseif( $('html').attr('lang') == 'pl-pl' ) {
        varhref = '/pl';
   }

User avatar
Moderator


cron