PHP Coding Problems With Languages

My project has around 35 more or less static pages and is trilingual - well almost. Some are translated in all three languages, some have two, some are only in one language.

That’s why the design of the language picker is non-standard. If the page exists in another language, the corresponding button shows up. (See pics below) Therefore, I created radio buttons in the panel (See pic below) and the corresponding php snippets. However, my PHP knowledge lets me down. This piece of code doesn’t work unfortunately:

<?php if ($page->languageOne()->isNotEmpty()): ?>

„<a“ class="border border-400 mr-2 px-2 py-1 rounded text-white tr-color" href="<?= $page->language('tr')->text() ?>">TR „<„/a>“
<?php endif ?>

I would appreciate any help and thank you in advance.

Best,

Nedim

example1 example-2 panel-screenshot

What are these radio buttons supposed to do? Where (as in: in which blueprint) are they implemented? What is languageOne etc?

A regular language picker does not come in question in this project. Only the other available languages should be visible in each particular page. Following this logic, a page let’s say in German could have at most two other languages to choose from: Turkish and/or English. Vice versa in the another language, e.g. a page in English would have German and/or Turkish.
The reason for having to radio buttons is to trigger the possibility to show none, one or two buttons on the page. LanguageOne and languageTwo are only there for the order in which they are shown on the page.
The radio buttons are supposed to say, for example:

  • create a language-button on place 1 in the TR language
    Or e.g.
  • don’t create language-button on place 2

I put the Blueprint files in the fields folder:

label:
  en: LanguageOne
  tr: LanguageOne
  de: LanguageOne
type: radio
options:
  NO: None
  TR: Turkish
  EN: English
  DE: German
  en: LanguageTwo
  es_ES: LanguageTwo
  de: LanguageTwo
type: radio
options:
  NO: None
  TR: Turkish
  EN: English
  DE: German

The entry in the page template goes like this:

      columnSidebar:
        width: 1/3
        sections:
          sectionPages:
            headline:
              en: Subpages
              tr: Altsayfa
              de: Unterseiten
            type: pages
            create:
              - film
              - serien
              - radio
              - achtziger
              - plain
            templates:
              - film
              - serien
              - radio
              - achtziger
              - plain
          sectionFiles:
            headline:
              en: Files
              tr: Arsiv
              de: Dateien
            type: files
          sectionMedia:
            type: fields
            fields:
              layout: fields/layout
              thumbnail: fields/thumbnail
              pictureCaption: fields/pictureCaption
              date: fields/date
              video: fields/video
              languageOne: fields/languageOne
              languageTwo: fields/languageTwo
              tags: fields/tags

„TR.php“ and „EN.php“ are in the snippets folder with the following code which I already posted yesterday:

<?php if ($page->languageOne()->isNotEmpty()): ?>
<a class="border border-400 mr-2 px-2 py-1 rounded text-white tr-color" href="<?= $page->language('tr')->text() ?>">TR </a>
<?php endif ?>

I put quotation marks around the html link code because I don’t know how to place code here and it is rendered as a link. :slight_smile:

I already sent you links of a particular page in my other topic. The language links there are put in manually and don’t work anyway. When I use the php code above, the page does not render the right way.

Best,

Nedim

I’ll look into this tonight.

Thanks for your efforts.

Just for your information: I am working with a them called KIII. And by the way, the getkirby-themes website points to the hosting service at the moment. At least on my browsers.

Best,

Nedim

Yes, thank you, we are aware of that. But the getkirby-themes website is a third party project and we have contacted the owner.

I solved the problem with a more o less manual way.

I created fields for the slugs of each language, which I input manually. The fields don’t show up if they are empty.

That works and it’s enough for my workflow.

Thanks for your efforts texnixe anyway.

Best,

Nedim