# Echo blueprint fields label title

**URL:** <https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564>\
**Category:** Questions\
**Tags:** v2\
**Created:** [July 8, 2015, 2:04pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564 "2015-07-08T14:04:31Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![lsg](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@lsg](https://forum.getkirby.com/u/lsg)\
**Post date:** [July 8, 2015, 2:04pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/1 "2015-07-08T14:04:31Z")

</div>

Hello Kirby-ers,

I have a set of custom fields in my blueprints. Is there a way to display the title/label of a blueprint field conditionally?

Suppose I have:

```
year:
label: Year/Jaar
type: text

```

How can I get to show ‘Year/Jaar’? Something like \<?php echo $page-\>year()-\>label() ?\>, does that exist? Obviously I can use html to put it in my template, but the thing is I would like to show it conditionally only when the field is actually filled in.  
Can somebody help out?

---

<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:** [July 8, 2015, 2:13pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/2 "2015-07-08T14:13:16Z")

</div>

You can’t get the label of a field, because it only exists in the panel, not in the text file. However, you could still do it conditionally (at least if I got you right)

```php
<?php if($page->year() != "") :?>
<span>Year/Jaar</span><span><?php echo $page->year() ?></span>
<?php endif ?>

```

BTW: Is that a multi-lingual site? Then you could use language specific labels in the panel and also use language variables for the template output.

---

<div class="post-metadata">

**Author:** ![Targoran](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/targoran/32/733_2.png) [@Targoran](https://forum.getkirby.com/u/Targoran)\
**Post date:** [July 8, 2015, 2:26pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/3 "2015-07-08T14:26:42Z")

</div>

Kirby has a field method to check if it’s not empty: In this case it would be:

```php
$page->year()->isNotEmpty()

```

As for language-specific labels, you could use this in your blueprint:

```
year:
  label: 
    en: Year
    nl: Jaar
  type: text

```

But you would need to enable multi-language support in order to use it, as it will only show the according field label when the language is switched in the panel.

---

<div class="post-metadata">

**Author:** ![anon77445132](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@anon77445132](https://forum.getkirby.com/u/anon77445132)\
**Post date:** [July 8, 2015, 2:49pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/4 "2015-07-08T14:49:42Z")

</div>

> [@texnixe](#):
>
> You can’t get the label of a field

With [Kirky docs: Advanced \> Custom field methods \> The field object](http://getkirby.com/docs/advanced/field-methods#the-field-object):

In a snippet or a template I think we can get the “the name of the field” (label) with the code `$field->key` (not yet tested).

---

<div class="post-metadata">

**Author:** ![Targoran](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/targoran/32/733_2.png) [@Targoran](https://forum.getkirby.com/u/Targoran)\
**Post date:** [July 8, 2015, 2:53pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/5 "2015-07-08T14:53:03Z")

</div>

> [@anon77445132](#):
>
> In a snippet or a template I think we can get the “the name of the field” (label) with the code $field-\>key (not yet tested).

The name of the field is not the same as the label, though.  
In his case the key is `client`, but the label is `Year/Jaar`.  
I think what @lsg wants is to display Year/Jaar, so unfortunately the key isn’t of any help here.

---

<div class="post-metadata">

**Author:** ![anon77445132](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@anon77445132](https://forum.getkirby.com/u/anon77445132)\
**Post date:** [July 8, 2015, 2:57pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/6 "2015-07-08T14:57:27Z")

</div>

O, then it is the same as to get the label of an options of a Radiobuttons field.

---

<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:** [July 8, 2015, 3:06pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/7 "2015-07-08T15:06:43Z")

</div>

That’s yet another story.

---

<div class="post-metadata">

**Author:** ![anon77445132](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@anon77445132](https://forum.getkirby.com/u/anon77445132)\
**Post date:** [July 8, 2015, 3:24pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/8 "2015-07-08T15:24:04Z")

</div>

I have added an issue: [Add `$field->label` to get the label of a panel field](http://forum.getkirby.com/t/add-field-label-to-get-the-label-of-a-panel-field/1565/1)

---

<div class="post-metadata">

**Author:** ![lsg](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@lsg](https://forum.getkirby.com/u/lsg)\
**Post date:** [July 8, 2015, 4:02pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/9 "2015-07-08T16:02:44Z")

</div>

As for me, the code Texnixe wrote works perfectly! That is exactly what I meant…  
Thanks!

Concerning the multilingual aspect, we have not yet decided which direction to take, but thank you for informing me on this possibility, I was not aware of that option!

---

<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:** [July 8, 2015, 4:31pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/10 "2015-07-08T16:31:16Z")

</div>

A work-around for getting those labels is mapping the desired key-value pairs in your config, like so:

```php
c::set('year', 'Year/Jaar');

```

Then in your template, you can retrieve the desired value:

```php
<?php echo c::get($page->year()->key()); ?>

```

Or as an array of values:

```php
  c::set(array(
   'year' => 'Year',
   'title' => 'Title',
   'text' => 'Text'
  ));

```

This is also useful if you want to get the “readable” strings for your radio button/select/checkbox values.

And if you are on a multi-language site, you can define those key=\>value pairs in your language files.

en.php

```php
<?php
  l::set('year', 'Year');
  l::set('text', 'Text');
?>

```

nl.php

```php
<?php
  l::set('year', 'Jaar');
  l::set('text', 'Tekst');
?>

```

And in your template:

```php
<?php echo l::get($page->year()->key()); ?>

```

---

<div class="post-metadata">

**Author:** ![fhmi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/fhmi/32/5770_2.png) [@fhmi](https://forum.getkirby.com/u/fhmi)\
**Post date:** [June 9, 2017, 11:30pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/11 "2017-06-09T23:30:39Z")

</div>

You can use this plug-in for this kind of problems.

> **[AugustMiller/kirby-architect](https://github.com/AugustMiller/kirby-architect)**
>
> kirby-architect - 📐 Easily reference Blueprint data from anywhere in your Kirby application.

This helped me a lot.

Cheers

---

<div class="post-metadata">

**Author:** ![jenstornell](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jenstornell/32/546_2.png) [@jenstornell](https://forum.getkirby.com/u/jenstornell)\
**Post date:** [June 10, 2017, 9:41am UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/12 "2017-06-10T09:41:32Z")

</div>

An alternative is [https://github.com/jenstornell/kirby-blueprint-reader](https://github.com/jenstornell/kirby-blueprint-reader)

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 4:49pm UTC](https://forum.getkirby.com/t/echo-blueprint-fields-label-title/1564/13 "2025-02-06T16:49:46Z")

</div>


