Get multilingual url from query

I have a blueprint where my client can add pages to the footer (see blueprint). Unfortunately I do not know how to add a multilingual link. This code does not add the /en part: <?= str::slug($item) ?>

Any idea?

Blueprint:

subpages:
  label:
    en: Show page on footer
    de: Seite im Footer anzeigen
  type: checkboxes
  default: false
  options: query
  columns: 3
  query:
    page: /
    fetch: invisibleChildren
    value: '{{title}}'
    text: '{{title}}'
    flip: true

Snippet:

<?php foreach($site->subpages()->split() as $item): ?>
	<li class="menu__item<?php if($item == $page->title()): ?> is-active<?php endif ?>">
		<a href="<?= str::slug($item) ?>" class="menu__link menu__link--small"><?= html($item) ?></a>
	</li>
<?php endforeach ?>

May I ask why you store the titles of the pages instead of their URI (or in this case the uid would also work)?

With the pages stored with their URI, you can get the collection of pages like this:

$subpages = $site->subpages()->toPages(',');

Then loop through the collection like through any page collection and fetch the URL and title and whatever you need.

1 Like

BTW, if you want a more flexible solution for custom menus, I can highly recommend @ola’s Kirby relationship plugin

1 Like