Strange Bug on Multilanguage-Page for Titles

Hi there,

i have a very urgent problem with page titles on a page that went live yesterday evening. I cannot figure out where this error comes from and hope for some suggestions from you guys…

I have a menu as a sidebar, some breadcrumbs and a page title on almost every page. When an Headline is set in the backend, the page title gets replaced by that. Furthermore i have the URL-Key method for setting the URL to the english version.

In the sidebar menu, only translated pages are visible by filtering them out with the Translations Plugin from flokosiol. In english this setting is set for the trends and the sustainability pages. But now they appear, which they shouldn’t:

Somehow the german titles and statusses are getting pulled and i don’t know where the error may be. So as you can see the german title is getting pulled, although the english one is set.

As you can see none of the methods (that are default and used many times) works properly at this point…

I’m really thankful for any kind of help, as it’s really urgent.

Thanks so far.
Tobi

Hey Tobi,

please post your code (all that is necessary to understand this, blueprints, template code etc). The result is not really useful for finding out where the error might be.

Hi Texnixe,

i try to send the (important) code:

Snippet for showing the Page Title (e.g. Headline)

<section id="page-title" class="page-title__wrapper col-1-1">
	<div class="page-title__holder grid">
		<div class="col-1-1">
  		<h1><?= e($page->headline()->isNotEmpty(), $page->headline()->html(), $page->title()) ?></h1>
  		</div>
	</div>
</section>

I think this is self-explaining…

And the Snippet for the Sidebar-Menu (Adaptation from the default Menu):



$language = $site->language();

$excluded = new Pages;
$excluded->add($site->index()->filterBy('template','*=','module'));
$excluded->add($site->index()->filterBy('intendedTemplate','*=','modules'));


// nested menu
$items = $pages->visible()->not($excluded)->not('home')->not('impressum')->not('agb')->not('kontakt')->not('newsletter')->not('news')->filterBy('translations','1');

// only show the menu if items are available
if($items->count()):

?>
<aside class="submenu__holder">
  <div class="submenu__background"></div>
  <div class="submenu__content aside-menu">
    <ul class="submenu__tree level-one <?= $_SESSION['gender'] ?>">
      <?php foreach($items as $item): ?>
        <li class="submenu__leaf level-one">
          <a<?php e($item->isOpen(), ' class="active"') ?> href="<?php echo $item->url() ?>"><h3><?php echo $item->title()->html() ?></h3></a>
          
          <? if($item->hasVisibleChildren()): ?>
            <?php

            // get all children for the current menu item

            $children = $item->children()->not($excluded)->filterBy('translations','1');

            // display the submenu if children are available
            if($children->count() > 0):

            ?>
            <ul class="submenu__tree level-two">
              <?php foreach($children as $child): ?>
              <li class="submenu__leaf level-two">
      	        <a<?php e($child->isOpen(), ' class="active"') ?> href="<?php echo $child->url() ?>"><?php echo $child->title()->html() ?>
      	        	
      	        </a>
              </li>
              <?php endforeach ?>
            </ul>
            <?php endif ?> 
          <? endif ?>
        </li>
      <?php endforeach ?>
      <? $subitems = new Pages; ?>
      <? $subitems->add(page('kontakt'))->add(page('impressum'))->add(page('agb')); ?>
      <ul class="submenu__tree level-two">
      <?php foreach($subitems as $item): ?>
        <li class="submenu__leaf level-two">
          <a<?php e($item->isOpen(), ' class="active"') ?> href="<?php echo $item->url() ?>"><?php echo $item->title()->html() ?></a>
          
        </li>
      <?php endforeach ?>
      </ul>
      <a class="underline" href="<?= $site->contactFB()->html() ?>" target="_blank">Facebook</a>
    </ul>
  </div>
</aside>
<?php endif ?>

And the Breadcrumb Snippet (also quite simple):

<nav class="breadcrumbs grid" itemprop="breadcrumb">

  <span prefix="v: http://rdf.data-vocabulary.org/#">
    <?php foreach($site->breadcrumb() AS $crumb): ?>
    <?php if ($crumb->isActive()): ?>
      <span typeof="v:Breadcrumb">
        <span class="breadcrumb__last" property="v:title">
          <?php echo $crumb->title() ?>
        </span>
      </span>
      <?php else: ?>
      <span typeof="v:Breadcrumb">
        <a class="breadcrumb__path-anchor" href="<?php echo $crumb->url() ?>" rel="v:url" property="v:title">
          <?php echo $crumb->title() ?>
        </a>
      </span>
    <?php endif ?>
    <?php endforeach ?>
  </span>
</nav>

I think the error is somewhere else…

Tobi

And i think since it has been working properly all the times, that the error is somewhere else. We have been changing some URL-Keys in the near past, maybe this makes some problems? But i can’t figure out where we changed anythin, that conflicts with that, since this is such a default functionality…

What is your site’s default language? If it is German, than I would expect them to be added.

  • PS: What language is the website in where you’ve took screenshots?
  • PS 2: On which pages is “translations” field “1”?

Default language is German. The screenshots were taken on the English page. The field is 1 for every page you see in the English menu. Except for Leistungen and Nachhaltigkeit. What bothers me more is that there are different titles set in English but they only show up at the Leistungen leaf of the menu…

1 problem at a time: headers first.

for the “services” page -> Is the headline field filled in (== not empty) in the English version?

Yes it is. And has been all the time…

What is

var_dump($page->headline()->isNotEmpty());
var_dump($page->headline()->html());
var_dump($page->title());

for the English version of “services” ?

And is the filename correct? services.en.md or something?

I cannot test it at the moment because I’m out. But the template is overview-page.php and the text file is overview-page.en.txt…

@ToGe88:
And there is NO file like overview-page.txt (any .txt file without any language-code in it’s name) in your content directory?

No there is not:

That’s what i thought at first and what i always check when something like this occurs…

So first of all thank you for your support. The forum is helpful as always. But as i assumed, the problem was somewhere else. Yesterday i initialized the redirects plugin for simple 301 redirects: https://gist.github.com/mogelbrod/5e5c64ff943ba6909ce3bd35a57bc808

I removed this plugin and tada: functionality same as before.

Maybe someone knows why this happened, therefore i give you a screenshot from the backend with the redirects (Old URL on the left, new one on the right):

Thanks so far
Tobi

I had thought that there were some routes involved. I think the problem is that your new routes contain the language code.

Hmmm and would be the best way to do this? Without the lang code?

I’d try without the lang code, the way the new page is called in the route doesn’t make sense with the language code, or rather, the route would have to work differently. Otherwise I’d do this via the .htaccess or ideally via the server config file.

So i tried it without the language code. That didn’t help. What’s the best way to do this with htaccess for Kirby?

Here is an example from a httpd.conf file (you can use this in your .htaccess as well):

Redirect 301 "/referenzen.html" "/referenzen"
Redirect 301 "/Arbeit.html" "/leistungen"
Redirect 301 "/Kontakt.html" "/kontakt"
Redirect 301 "/wirueberuns.html" "/ueber-uns"
Redirect 301 "/Ansprechpartner.html" "/ueber-uns"
Redirect 301 "/leistungen.html" "/leistungen"
Redirect 301 "/Organisation.html" "/leistungen"
Redirect 301 "/kunden.html" "/referenzen"
Redirect 301 "/Impressum.html" "/impressum"
Redirect 301 "/jobs.html" "/"
Redirect 301 "/index.html" "/"
#RedirectMatch 301 "/(.+)\.html$" "/"

In your use case, you would use the new url with the language code though.

O.K. I’m gonna give it a try tomorrow. Thanks so far. So you do think that this would solve this problem or would the error occur again?

Thanks Tobi

I haven’t tested this with a multi-language site. I recommend that you test this on localhost or a dev server first before you deploy to production.