# Switch toggle - output of field values in snippet

**URL:** <https://forum.getkirby.com/t/switch-toggle-output-of-field-values-in-snippet/20002>\
**Category:** Questions\
**Tags:** v3\
**Created:** [November 9, 2020, 6:34pm UTC](https://forum.getkirby.com/t/switch-toggle-output-of-field-values-in-snippet/20002 "2020-11-09T18:34:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thinktruenorth](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@thinktruenorth](https://forum.getkirby.com/u/thinktruenorth)\
**Post date:** [November 9, 2020, 6:34pm UTC](https://forum.getkirby.com/t/switch-toggle-output-of-field-values-in-snippet/20002/1 "2020-11-09T18:34:26Z")

</div>

Hi guys,  
I spent quite some time finding a solution for my specific problem and since I am new to Kirby as well as PHP, I am trying to read and learn as much as I can.  
Maybe you can help with one specific problem that I have.

In my page blueprint I do have the following code:

```
card_type:
label: card type
type: select
default: Summary with large image
  options:
    summary: Summary
    summary_large_image: Summary with large image
    app: App Link
    player: Video Link

```

The problem I have with that is that in the snippet template, I can’t get a proper output of the selected option into my source code.

Maybe someone can help with that.  
I tried for example:

```
`<meta name="twitter:card" content="<?= $field = $page->blueprint()->field('card_type'); $value = $page->category()->value(); echo $field['options'][$value] ?? $value;?>" />`

```

but unfortunately, that did not help.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [November 9, 2020, 7:16pm UTC](https://forum.getkirby.com/t/switch-toggle-output-of-field-values-in-snippet/20002/2 "2020-11-09T19:16:05Z")

</div>

> [@thinktruenorth](#):
>
> I am trying to read and learn as much as I can.

Great! Welcome to our community 👋!

I assume you want to get the text that is assigned to the value that is stored in your options, right? So instead of outputting `summary_large_image` you want to print “Summary with large image”.

You already found the right documentation, but of course you cannot just put all that PHP into the content attribute, but have to get the value first, then echo that inside the content attribute.

```auto
<?php
$value = $page->card_type()->value();
$field = $page->blueprint()->field('card_type');
$value = $field['options'][$value] ?? '';
?>
<meta name="twitter:card" content="<?= $value ?>" />

```

To keep your code clean, you could outsource all that stuff into a field method (but that’s maybe a bit too much if you’re just starting out with PHP and Kirby 😉 ).

Additionally, you could use an if statement to check if the field is filled, before you actually do all this.

---

<div class="post-metadata">

**Author:** ![thinktruenorth](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@thinktruenorth](https://forum.getkirby.com/u/thinktruenorth)\
**Post date:** [November 9, 2020, 11:05pm UTC](https://forum.getkirby.com/t/switch-toggle-output-of-field-values-in-snippet/20002/3 "2020-11-09T23:05:03Z")

</div>

thanks a lot for that quick solution! 🙂  
and of course for the warm welcome!
