# Panel: text block with 2 fields of texts

**URL:** <https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110>\
**Category:** Questions\
**Tags:** v3\
**Created:** [July 31, 2022, 9:58am UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110 "2022-07-31T09:58:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nirsh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nirsh/32/11552_2.png) [@nirsh](https://forum.getkirby.com/u/nirsh)\
**Post date:** [July 31, 2022, 9:58am UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110/1 "2022-07-31T09:58:19Z")

</div>

Hi!  
I try to add another field in the text block and I struggle a little bit.  
I have this blocks yml:

```auto
  - width: 1/2
      type: fields
      fields:
        notes:
          type: blocks
          fieldsets:
                - text
                - image

```

I want that the client will be able to add a caption either for an image and for the text as well.  
so actually I need a text block with two text fields.  
So I changed the text.yml to this:

```auto
name: field.blocks.text.name
icon: text
wysiwyg: true
preview: text
fields:
  text:
    type: writer
    nodes: false
    placeholder: field.blocks.text.placeholder
  caption:
    type: writer
    nodes: false

```

now if I click on the text block to add text I get only 1 field:

 ![Screen Shot 2022-07-31 at 12.52.35 PM](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/f/f3ad1801fe9817b2f4f82d214b5ce224bfeabe57.png)

But if I click on the ‘edit’ button I can see the two fields:

 ![Screen Shot 2022-07-31 at 12.53.01 PM](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/1/11bdd130fde89624bd9bbd55b4df9f47562e6e23.png)

How can I get the two fields block in the first click?

thanks a lot!

---

<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 31, 2022, 10:10am UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110/2 "2022-07-31T10:10:40Z")

</div>

> [@nirsh](#):
>
> ```auto
> name: field.blocks.text.name
> icon: text
> wysiwyg: true
> preview: text
> fields:
> text:
> type: writer
> nodes: false
> placeholder: field.blocks.text.placeholder
> caption:
> type: writer
> nodes: false
> 
> ```

You would have to create a new preview if you want the second field to show up there as well.

> **[Page builder](https://getkirby.com/docs/guide/page-builder)**
>
> Create rich content or even complete page layouts right from the Panel

> **[Modifying blocks types and custom blocks](https://getkirby.com/docs/cookbook/panel/block-basics#custom-block-types)**
>
> Learn the basics of modifying our core blocks and creating your own from scratch

---

<div class="post-metadata">

**Author:** ![nirsh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nirsh/32/11552_2.png) [@nirsh](https://forum.getkirby.com/u/nirsh)\
**Post date:** [July 31, 2022, 3:10pm UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110/3 "2022-07-31T15:10:30Z")

</div>

thanks!  
Eventually [this article](https://getkirby.com/docs/reference/plugins/extensions/blocks#simple-preview) had exactly what I needed. I created a new plugin for a custom footnote block and it works perfectly.

I have another question related to this subject:  
I wish to add a **custom id** field for the image fieldset in the blocks.  
I changed the image yml file and added a new field for that.

Now I want the **custom id** to be shown next to the image in the panel. Since I use the image block in several pages - I want this custom id to be shown only in a specific page in the panel…  
So my question is this:  
should I create a new custom field for that with a new plugin?  
or can I change the preview of the image block only in a specific page?

I’m a bit confused… this is my yml:

```auto
  - width: 1/2
      type: fields
      fields:
        notes:
          type: blocks
          fieldsets:
            text:
              label: foot note
              type: group
              fieldsets:
                footnote:
                  name: Foot note
                  fields: 
                    text: 
                      type: text
                    customid:
                      label: number of foot no
                      type: text
            media:
              label: painting
              type: group
              fieldsets:
                - image

```

I hope it is understood. I would appreciate any help,  
Thanks!

---

<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 31, 2022, 4:08pm UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110/4 "2022-07-31T16:08:16Z")

</div>

> [@nirsh](#):
>
> or can I change the preview of the image block only in a specific page?

I think it’s probably better if you create a custom block. Otherwise you’d need a way to check if you are on a given page (via the URL for example), and then show the id conditionally.

---

<div class="post-metadata">

**Author:** ![nirsh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nirsh/32/11552_2.png) [@nirsh](https://forum.getkirby.com/u/nirsh)\
**Post date:** [July 31, 2022, 4:21pm UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110/5 "2022-07-31T16:21:47Z")

</div>

Ok - Ill do that

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![nirsh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nirsh/32/11552_2.png) [@nirsh](https://forum.getkirby.com/u/nirsh)\
**Post date:** [August 1, 2022, 8:24am UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110/6 "2022-08-01T08:24:49Z")

</div>

I have an issue with creating a new image custom block:  
I try to create a plugin for it (index.js, index.css, index.php) and since I use ‘type: files’ in my yml file, I’m not quite how should I call it in the index.js to get the preview of the image. This is my poor try:

```auto
panel.plugin("shish/footimg-block", {
    blocks: {
      footimg: `
        <img @click="open" src='{{ content.img }}' >
      `
    }
  });

```

this is my yml:

```auto
            media:
              label: painting
              type: group
              fieldsets:
                footimg:
                  name: image
                  fields: 
                    img:
                      type: files
                    caption:
                      type: text
                    id:
                      type: text

```

and it’s not working:

 ![Screen Shot 2022-08-01 at 11.21.57 AM](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/9/9d63585e18d8da92fabbbabea390653ccec05407.png)

Any idea how to preview image file in the preview?

Thanks so much!

---

<div class="post-metadata">

**Author:** ![nirsh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nirsh/32/11552_2.png) [@nirsh](https://forum.getkirby.com/u/nirsh)\
**Post date:** [August 1, 2022, 9:44am UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110/7 "2022-08-01T09:44:48Z")

</div>

When I type inside the index.js the {{ content.img }} outside the img tag it gives me all the image details:

```auto
[
    {
      "content": {
        "img": [ 
          {
            "id": "texts/new-text/02_francisco_de_goya-_saturno_devorando_a_su_hijo_-1819-1823-1.jpg",
            "image": {
              "back": "pattern",
              "color": "orange-400",
              "cover": false,
              "icon": "file-image",
              "ratio": "3/2",
              "url": "http://localhost:8000/media/pages/texts/new-text/c3cf25f2a6-1656838038/02_francisco_de_goya-_saturno_devorando_a_su_hijo_-1819-1823-1.jpg",
              "src": "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw",
              "srcset": "http://localhost:8000/media/pages/texts/new-text/c3cf25f2a6-1656838038/02-francisco-de-goya-saturno-devorando-a-su-hijo-1819-1823-1-38x.jpg 38w, http://localhost:8000/media/pages/texts/new-text/c3cf25f2a6-1656838038/02-francisco-de-goya-saturno-devorando-a-su-hijo-1819-1823-1-76x.jpg 76w"
            },
            "info": "",
            "link": "/pages/texts+new-text/files/02_francisco_de_goya-_saturno_devorando_a_su_hijo_-1819-1823-1.jpg",
            "sortable": true,
            "text": "02_francisco_de_goya-_saturno_devorando_a_su_hijo_-1819-1823-1.jpg",
            "filename": "02_francisco_de_goya-_saturno_devorando_a_su_hijo_-1819-1823-1.jpg",
            "dragText": "(image: 02_francisco_de_goya-_saturno_devorando_a_su_hijo_-1819-1823-1.jpg)",
            "type": "image",
            "url": "http://localhost:8000/media/pages/texts/new-text/c3cf25f2a6-1656838038/02_francisco_de_goya-_saturno_devorando_a_su_hijo_-1819-1823-1.jpg",
            "uuid": "02_francisco_de_goya-_saturno_devorando_a_su_hijo_-1819-1823-1.jpg"
          }
        ],
        "caption": "sdf",
        "id": "19"
      },
      "id": "0d220d09-7318-4193-876f-d6fce754cd23",
      "isHidden": false,
      "type": "footimg"
    }
  ]

```

But for some reason, no matter how I try - I can’t fetch it, for example:

```auto
<img src='{{ content.img.link }}'>

```

I feel that I’m very close to figure it out - please help 🙏

---

<div class="post-metadata">

**Author:** ![nirsh](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/nirsh/32/11552_2.png) [@nirsh](https://forum.getkirby.com/u/nirsh)\
**Post date:** [August 1, 2022, 9:50am UTC](https://forum.getkirby.com/t/panel-text-block-with-2-fields-of-texts/26110/8 "2022-08-01T09:50:30Z")

</div>

I found it, this is the correct syntax in the index.js:

```auto
<img :src='content.img[0].url' >

```

(hope someone will find it helpful)
