Wrong content shown in in Panel inside Multilang Structure Field

Hey there,

I’ve encountered an issue that I think might be a bug. I’ve already submitted an issue over on Github, but haven’t been able to find a solution yet:

In a multilanguage setup running the latest Kirby 4 RC, I’m facing an issue with some multilang content inside a structure field. Currently, there are two languages enabled: English (default) and German.
In my blueprint I set up a structure field that is translatable:

intro_popup_slides:
  label:
    en: Popup Slides
    de: Popup Slides
  min: 1
  max: 10
  type: structure
  translate: true
  required: true
  fields:
    slide_headline:
      label:
        en: Headline
        de: Überschrift
      type: text
      maxlength: 60
    slide_mainttext:
      label:
        en: Main Text
        de: Haupttext
      type: textarea
      required: true
      maxlength: 450

While the field works as expected when I enter english Content, there is an issue when entering german content: The field value gets saved and appears inside the content files (contentfile.en.txt and contentfile.de.txt) as expected. As soon as I refresh the panel though, the English content of the field is shown despite the panels language toggle being set to German.

This issue only concerns the panel: As the contentfiles are updated properly, the right content is also being shown in my templates – not seeing the right content just makes it very hard for my client to edit the page.

Tested with Kirby 4.RC1 starter kit.
I could not detect any abnormalities.
Perhaps I have not understood your problem correctly.

screenrecord

I believe you understood my problem correctly. For me it looks like this:

LangError

I have already disabled all plugins but that didn’t help. One thing that comes to my mind is that I recently migrated some content from an older Version of the site I’m working on. But that happened on a different level in the file system, so I don’t think it should be causing any issues here.

That doesn’t look normal.
I would test this with a fresh starter kit to rule out that it is a Kirby error.
Then you can also use the new RC2:

I would also try to check the .txt for unused entries or entries with the same name. Perhaps an error has crept in there due to the migration.

There is also a script that cleans up .txt. This has often helped me.
It is important to create a backup beforehand in case of an error.

Thanks for your replies, @GB_DESIGN! I have now actually found the source of the issue. As it turns out, the migrated content wasn’t the problem and there also weren’t any duplicate fields.

Inside my config.php, I set up some modifications of the panel sidebar: The page I’m referring to should show up in the sidebar for admin users to be easily accessible:

    'ready' => function() {
        // create custom sidebar based on role
        if(kirby()->user()?->role() == 'admin'){

            $items = [
                'site',
                'reusable_content' => [
                    'label' => kirby()->page('reusable-content')->title()->toString(),
                    'link' => kirby()->page('reusable-content')->panel()->url(),
                    'icon' => 'divider'
                ],
                'challenge_content' => [
                    'label' => kirby()->page('challenge-content')->title()->toString(),
                    'link' => kirby()->page('challenge-content')->panel()->url(),
                    'icon' => 'divider'
                ],
                'someotherpage' => [
                    'label' => kirby()->page('someotherpage')->title()->toString(),
                    'link' => kirby()->page('someotherpage')->panel()->url(),
                    'icon' => 'chat'
                ],
                'languages',
                'users',
                'system'
            ];

            return [
                'panel.menu' => $items
            ];
        }

This seemed to work, but apparently caused the translation issue. Not sure why, but when I removed the code, the translations start to show up properly again. If this is not the proper way to add items to the sidebar, is there a recommended way to do it @texnixe?

Pretty sure this happens because the language context is missing here when you access your content via these urls.

Hi Sonja, not sure if that’s actually the case: The problems happens regardless of wether I navigated to that page using my modified sidebar or if I navigated to the page using the regular path through Site > Pages > Challenge Content.

If the problem is in fact the missing language context, is there a suggested way to make it available here?

I tried setting the menu without the ready option, and then it works as expected (but you do not have access to the Kirby object in that case).

Don’t know if this is a bug or due to loading order.

It also works with hardcoded strings:

	'ready' => function() {
		if(kirby()->user()?->role() === 'admin') {
			return [
				'panel.menu' => [
					'site',
					'notes' => [
						'label' => 'Notes',
						'link' => 'pages/notes',
						'icon'  => 'divider'
					],
					'languages',
					'users',
					'system'
				],
			];
		}
	},

So the problem seems to be due to the call to kirby()->page().