Hello,
I am trying this method to translate user added tags: Translatable user added tags - #4 by texnixe, but i don’t really get the last part:
Then in the frontend use the tags field stored value to loop over the structure field, match entry, and fetch the translations
Inside site.yml file i have a structure with translations:
tagsTranslation:
label: Translations
type: structure
translate: false
fields:
lt:
label: LT
type: text
en:
label: EN
type: text
Then inside event-article.yml I have tags field for event categories with options querying from the site structure:
#category
category:
label: Category
type: tags
accept: options
translate: false
options:
type: query
query: site.tagsTranslation.toStructure
text: "{{ item.lt }}"
# value: "{{ item.lt }}"
And finally home.php template file:
<!-- events dates -->
<div class="events--dates" id="events--dates">
<?php foreach($events as $eventPost): ?>
<?php foreach($site->tagsTranslation()->toStructure() as $translation): ?>
<p class="info-text">
<?php if($kirby->language() == 'lt'): ?>
<?php
echo $translation->lt();
?>
<?php endif; ?>
<?php if($kirby->language() == 'en'): ?>
<?php
echo $translation->en();
?>
<?php endif; ?>
</p>
<?php endforeach; ?>
<?php endforeach; ?>
But how can i check if structure entries inside site.yml do match with the selected tags inside event page and then displaying only those matched entries?
Because right now i get all declared tags inside site.yml structure:
Any input is really appreciated, thank you.