# Wrong $page-\>field()-\>kirbytext() output

**URL:** <https://forum.getkirby.com/t/wrong-page-field-kirbytext-output/10950>\
**Category:** Questions\
**Tags:** v2\
**Created:** [July 31, 2018, 9:21pm UTC](https://forum.getkirby.com/t/wrong-page-field-kirbytext-output/10950 "2018-07-31T21:21:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [July 31, 2018, 9:21pm UTC](https://forum.getkirby.com/t/wrong-page-field-kirbytext-output/10950/1 "2018-07-31T21:21:04Z")

</div>

Hello,

I have the problem that kirbytext () automatically closes a .

_ **blueprint** _  
gallery:  
label: Galerie  
type: structure  
style: table  
fields:  
gallery\_img:  
label: Bild  
type: image  
caption:  
label: Bild-Untertitel  
type: simplemde

**panel input**  
test (email:text@text.ch text: test) test

**raw output**  
caption: ‘test (email:text@text.ch text: test) test’

**template**

```
   foreach($image_collection as $single_image): ?>

    <?php 
    $counter++;
    ?>

    <?php
    $image = $single_image->gallery_img()->toFile();
       
    $thumbURL = $image? $image->resize(2000)->url(): '';
    $thumbURL_mobile = $image? $image->resize(800)->url(): '';

    ?>
      <li class="col-dont-break-inside" id="<?php echo $gallery_name.$counter ?>" >
                              
          <a class="gallery-image flex-column justify-content-spacebetween" href="<?php echo '#'.$gallery_name.$counter ?>">
           
            
            <span class="caption"> 
            
              <?php
              
                echo $single_image->caption()->kirbytext();
            
              ?>

            </span>
            <div>
              <img src=<?php echo $thumbURL ?>>
            </div>

          </a>

```

**html output**

```
<li class="col-dont-break-inside" id="gallery-1-3">
                              
          <a class="gallery-image flex-column justify-content-spacebetween" href="#gallery-1-3">

            <span class="caption"> 
            <p>
              </p></span></a><p><a class="gallery-image flex-column justify-content-spacebetween" href="#gallery-1-3">test </a><a href="mailto:">test</a> test</p> <p></p>
            
            <div>

```

---

<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, 2018, 9:44pm UTC](https://forum.getkirby.com/t/wrong-page-field-kirbytext-output/10950/2 "2018-07-31T21:44:37Z")

</div>

The problem is in your markup, because you use an mailto anker link within an anker element.

Also, but not related to your issue, you shouldn’t use kirbytext within a span element, because using a block element inside an inline element like span is not valid HTML.

---

<div class="post-metadata">

**Author:** ![Perry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/perry/32/1336_2.png) [@Perry](https://forum.getkirby.com/u/Perry)\
**Post date:** [August 1, 2018, 9:50am UTC](https://forum.getkirby.com/t/wrong-page-field-kirbytext-output/10950/3 "2018-08-01T09:50:29Z")

</div>

Thank you @texnixe for answering , I changed my template.  
But what I not understand is why kirbytext() close the a tag (before I changed the template) .

```
<!--GALLERY-->

  <?php
  $counter = 0;//counter for image id;
  $counter1 = 0;//counter for gallery name
  $counter1++;//counter to jump to next img
  $gallery_name = $gallery_name_unique."-";
  $image_arr = $collection;
  $structur_field = $structur_field_name;

  $image_collection = $collection->{$structur_field}()->toStructure();
  $structurfield_count = $collection->{$structur_field}()->toStructure()->count();

    foreach($image_collection as $single_image): ?>

    <?php 
    $counter++;
    ?>

    <?php
    $image = $single_image->gallery_img()->toFile();
       
    $thumbURL = $image? $image->resize(2000)->url(): '';
    $thumbURL_mobile = $image? $image->resize(800)->url(): '';

    ?>
      <li class="col-dont-break-inside" id="<?php echo $gallery_name.$counter ?>" >

          <?php if($single_image->caption() != ""): ?>
            <div class="caption"> 
              <?php  
                echo $single_image->caption()->kirbytext();
              ?>
            </div>  
          <?php endif ?>          
          <a class="gallery-image flex-column justify-content-spacebetween" href="<?php echo '#'.$gallery_name.$counter ?>">
           
             
           
            <div>
              <img src=<?php echo $thumbURL ?>>
            </div>

          </a>
          <img class="only-mobile" src=<?php echo $thumbURL_mobile ?>>
          <!-- Gallery-Close-Button -->
          <a title="close" href="#close" class="background-lightbox"></a>
          <a class="close" href="#close">close</a>
         <!-- Gallery-Navigation- -->
          <a style="margin-top:<?php echo $counter*25?>px;" class="gallery-nav-button" href="#<?php echo $gallery_name.$counter ?>">
          </a>

          <?php if($counter == $structurfield_count ) { ?>
          <a class="gallery-nav-button-center" href="#<?php echo $gallery_name."1" ?>"></a>
          <?php } else { $counter1++;?>

          <a class="gallery-nav-button-center" href="#<?php echo $gallery_name.$counter1; ?>"></a>

            <?php } ?>
      </li>
    <?php endforeach ?>
```

---

<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:** [August 1, 2018, 10:33am UTC](https://forum.getkirby.com/t/wrong-page-field-kirbytext-output/10950/4 "2018-08-01T10:33:14Z")

</div>

You should get the same unwanted result if you just manually add some anker element without any kirbytext. The browser closes the first open a tag when it encounters a new a tag.

---

<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, 5:26pm UTC](https://forum.getkirby.com/t/wrong-page-field-kirbytext-output/10950/5 "2025-02-06T17:26:38Z")

</div>

Archived on February 6, 2025, 5:26pm UTC


