Tag cloud - tag text

The tag cloud only gives me the tag value.
I’m looking for the tag text… how can I do this?

Blueprint:

fields:
  thumbnail:
    label: Thumbnail
    type: files
    max: 1
  tags:
    label: Model
    type: tags
    options:
      - value: models
        text: Model S
      - value: model3
        text: Model 3
      - value: modelx
        text: Model X
      - value: modely
        text: Model Y
    help: Model S, Model 3, Model X, Model Y

Template:

<?php
// fetch all tags
$tags = $page->children()->listed()->pluck('tags', ',', true);
?>
<ul class="tags">
  <?php foreach($tags as $tag): ?>
  <li>
    <a href="<?= url('gallery', ['params' => ['tag' => $tag]]) ?>">
      <?= $tag ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>

Currently I show: models, model3, modelx, modely
Result I want to show: Model S, Model 3, Model X, Model Y.

You have two/three options:

  1. Get the text values from your blueprint: Using blueprints in the frontend | Kirby CMS
  2. Create a key-value array in your config as option.
  3. In a multilanguage site, use translation variables.

How do I get the text values from tag-fields as page info? And how do I set default values in tag fields?

What do you mean, in the Panel?

Default values can be set as a comma separated list:

fields:
  tags:
    type: tags
    default: a, b, c

The default tags don’t work in my case. I have set a tags.yml in blueprints/fields. Content is:

label: Tags
type: tags
accept: options
options:
  - value: val1
    text: Value 1
  - value: val2
    text: Value 2

In my template blueprint there are the following settings:

fields:
  tags:
    extends: fields/tags
    default: val1, val2

Now in the panel there is nothing set in the tags field.


The second question belongs to a pages section. How do I get my text values as info output?
My sections/projects.yml:

type: pages
headline: Projekt
info: "{{ page.tags }}"
parent: page
template: project
empty: No projects available

{{ page.tags.text }} doesn’t work

You can only get the text values via the $page->blueprint() method (for more info see Using blueprints in the frontend | Kirby CMS), so you would need a custom page method /model method and use that in your info query.

As regards default values: Defaults are only ever assigned at page creation, not for existing pages.