How to encode German-Umlaute to be used in the Menu-Links?

Hi,

Example:
A Menu-Link (Title) in the textfile should name “Über uns” [About].
If i encode them with “Ü” then the link will not be translated, if i encode them with “Ü” then the menu-item would not be displayed.

The same will happen in the “Caption” of images.

Is this a Bug or Feature, or do i miss something?

I use Kirby 2.4.1.

I don’t quite understand your problem, I’m afraid. If your page title is “Über uns” and you render it in your menu like this:

<ul>
<?php foreach($pages->visible() as $p): ?>
  <li><a href="<?= $p->url() ?>"><?= $p->title()->html() ?></a></li>
<php endforeach ?>
</ul>

then you shouldn’t have any problems. No need to encode anything.

But I don’t understand the difference between these two options:

Ok, i am very new to Kirby and therefore i tuck the 2.4.1-Starterkit and changed for the first steps only the contents (text).

content\6-about\about.txt: (windows notation on the local drive before copied via FTP to the webserver)

Title: Ueber uns

Description: &Uuml;ber ...

Intro: Alternatives, &ouml;kologisches

this will be ok, with the exception of clearly missing German-Umlaute:
(Einfuehrung / Produkte / Dienstleistung / Technische Daten / Ueber uns / Kontakt)

but if i use:

Title: Über uns

will display nothing, the menu-item is simply gone:
(Einfuehrung / Produkte / Dienstleistung / Technische Daten / / Kontakt)

and again:

Title: &Uuml;ber uns

will not translate the HTML-entity into the correct char.

(Einfuehrung / Produkte / Dienstleistung / Technische Daten / &Uuml;ber uns / Kontakt)

In contrast: the Intro-Field witch is read with: <?= $page->intro()->kirbytext() ?>
will correctly translate the &ouml;kologisches into “ökologisches”.

The Menu-Snippet from the Toolkit looks like:


And again: the same problem is with:
content\2-products\1-komfort\komfort.txt
Text: …some text…
(image: Komfort5mWeb.jpg caption: Au&szlig;enansicht)

either wrong or completely gone.

What do i missing?

BTW: don’t worry,
1.) its on a password-protected subdomain (apache-webserver),
2.) i bought a prof.-license a few days a go.

Thanks in advance

Well, first of all, you don’t have to use HTML entities, but you can add text like normal.

In a fresh Starterkit, you should have the following line in the header snippet:

  <meta charset="utf-8">

If that line is present as it should be, please remove the # from the following line in your .htaccess:

# AddDefaultCharset UTF-8
1 Like

Yes, i have in the HTML:


Sorry, enabling the .htaccess-entry doesn’t help anything.
The question is, why does the text (menu-entry) disapear and not only the unrecognized character be market like in “kirbytext()”?

Thanks

Please check this post: No German umlauts

Can you provide the code you use to render your menu links?

I don’t think this is a Kirby related problem, must be something related to your server. If this does not help, please provide more information about your OS, PHP version etc.

1 Like

Hi texnixe,
i have setup a clean new Kirby Starterkit 2.4.1 on a fresh clean Strato-Webserver.
In addition you will see a clean static HTML-page to compare what the webserver is doing with HTML-entities. Furtermore, i have prepared a php-page with the server-infos.

The only two lines in the Starterkit what i have modified is:
1.) in the content/3-about/about.txt: "Title: Über uns"
2.) in the .htaccess: enabling (uncomment) the line “AddDefaultCharset UTF-8”.

You can see whats happen in the following line (on the kirby starterkit home):

&Uuml;ber uns

If you look on the HTML-entity, then it is clear (at least for me) that this encoding comes from Kirby and not from the webserver.

I will send you the access link via pm.

Thanks
hjr

Hi texnixe,

link: http://www.testserver.de/static/

hjr

What happens if you change the navigation snippet and remove the html method from the output?

<nav class="navigation column" role="navigation">
  <ul class="menu">
    <?php foreach($pages->visible() as $item): ?>
    <li class="menu-item<?= r($item->isOpen(), ' is-active') ?>">
      <a href="<?= $item->url() ?>"><?= $item->title() ?></a>
    </li>
    <?php endforeach ?>
  </ul>
</nav>

Hi texnixe,
this is working, but it is not a problem-solver as such, because it’s not the only place with entity problems, like i mentioned before.

The complete Starterkit is based on this “->html()”-routine, what means that the complete Starterkit can’t handle HTML-entities at all!

This means not only it can’t handle european-characters, also any special-characters like “TM”, “Euro” etc. are affected. For example, the custom-meta-tags, caption for images and so on are all affected.

No problem with that as such, if i know the reason, but is it flagged as a Bug and forwarded to development?
Will it be fixed in the next Kirby-release?

BTW: excuse my faulty first handling of the forums-editor, thus tampered the sense completely.

Thanks for your attention
hjr

Hi @HJR, I did a test with Xampp on Windows. I think your problem is caused by the fact that you probably haven’t saved your files as UTF-8 without BOM. Once you do, everything should work fine.

@HJR:

I agree to

You can look at

Hint:
Use https://notepad-plus-plus.org/ or http://portableapps.com/apps/development/notepadpp_portable like you need. It is free!

Hi, @texnixe and @anon77445132:

Is a 7-Bit-ASCII-file not UTF-8 compatible?
What is wrong on “named-entities”?

So far as iam now understand, the whole problem is not a matter of a file-format, rather then on the kirby-toolkit function “html()”.
This function is a filter-function and uses some php-functions like: “htmlspecialchars” without the 3rd-parameter.

You can check this by using plain php-functions, like i did.

Thanks

Well, one option would be to simply not use the html() method at all. You can also create your own custom field method. But as I said, saving the file in the correct format should actually solve the issue as well.

1 Like

Hi texnixe,
could you please reveal me how i should code a soft-hyphen (shy) in the “caption” of a image without named-entities?

If you would furnished me with a private mail address, then i could give you the access-rights to some samples on a live web-server.

regards

For me it works using &shy;, together with the kirbytext() or markdown() field methods, or, if you don’t want the html output produced by these method, use a custom function.

You can mail me via PM here in the forum or at sonja@getkirby.com.