Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-02-14 16:27:02

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 809
Website

Txp can't find an openingstag ... !?

Textpattern Warning: Closing tag without corresponding opening tag: </txp:images>.

I guess it has to do with “…” and ‘…’ … but I do need some fresh eyes … ;-)

<figure class="slide" role="figure" aria-label="caption">
<txp:images<txp:if_yield name="id"> id='<txp:yield name="id" />' </txp:if_yield>>
<a class="chocolat-image" href='<txp:smd_thumbnail type="1600"><txp:smd_thumbnail_info item="url" /></txp:smd_thumbnail>' title='<txp:image_info type="alt" />'>
<img<txp:if_yield name="id"> src="<txp:smd_thumbnail id='<txp:yield name="id" />' type="400"><txp:smd_thumbnail_info item="url" /></txp:smd_thumbnail>' alt='<txp:smd_thumbnail_info item="alt" />" srcset="<txp:smd_thumbnail id='<txp:yield name="id" />' type="400"><txp:smd_thumbnail_info item="url" /> 400w</txp:smd_thumbnail>, <txp:smd_thumbnail id='<txp:yield name="id" />' type="800"><txp:smd_thumbnail_info item="url" /> 800w</txp:smd_thumbnail>, <txp:smd_thumbnail id='<txp:yield name="id" />' type="1200"><txp:smd_thumbnail_info item="url" /> 1200w</txp:smd_thumbnail>" sizes="400px" loading="lazy" </txp:if_yield>/></a>
</txp:images>
</figure>

Last edited by RedFox (2020-02-14 16:33:48)

Offline

#2 2020-02-14 16:37:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,433
Website GitHub

Re: Txp can't find an openingstag ... !?

Yeah, your quotes need straightening and you also have an opening ' and a closing ". Untested but this might be closer:

<figure class="slide" role="figure" aria-label="caption">
   <txp:images<txp:if_yield name="id"> id='<txp:yield name="id" />'</txp:if_yield>>
      <a class="chocolat-image"
        href="<txp:smd_thumbnail type="1600"><txp:smd_thumbnail_info item="url" /></txp:smd_thumbnail>"
        title="<txp:image_info type="alt" />">
         <img<txp:if_yield name="id"> src="<txp:smd_thumbnail id='<txp:yield name="id" />' type="400"><txp:smd_thumbnail_info item="url" /></txp:smd_thumbnail>"
            alt="<txp:smd_thumbnail_info item="alt" />"
            srcset="<txp:smd_thumbnail id='<txp:yield name="id" />' type="400"><txp:smd_thumbnail_info item="url" /> 400w</txp:smd_thumbnail>,
                    <txp:smd_thumbnail id='<txp:yield name="id" />' type="800"><txp:smd_thumbnail_info item="url" /> 800w</txp:smd_thumbnail>,
                    <txp:smd_thumbnail id='<txp:yield name="id" />' type="1200"><txp:smd_thumbnail_info item="url" /> 1200w</txp:smd_thumbnail>"
            sizes="400px" loading="lazy" </txp:if_yield>/>
      </a>
   </txp:images>
</figure>

Not sure of the overall logic, though. What happens if there’s no ‘id’ attribute? You’ll get an empty <img> tag. You could add a <txp:else /> and specify a fallback ‘no image yet’ pic?

This will be able to be a lot more streamlined in a week or two under 4.8.0!

EDIT: and, yeah, see Uli’s point too.

Last edited by Bloke (2020-02-14 16:52:44)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2020-02-14 16:50:02

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Txp can't find an openingstag ... !?

RedFox wrote #321660:

<txp:images<txp:if_yield name=“id”> id=’<txp:yield name=“id” />’ </txp:if_yield>>

Shouldn’t it be <txp:images id='<txp:if_yield name="id"><txp:yield name="id" /></txp:if_yield>' >? I.e. tags inside tags attributes, not tags inside tags.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2020-02-14 21:37:25

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,712
Website

Re: Txp can't find an openingstag ... !?

Another possible option: could you get away with just?

<txp:images id='<txp:yield name="id" />'>
…

Assuming that <txp:images id=''>… is the same as just <txp:images>…, that would mean that not specifying an id attribute in your shortcode should use the context-aware option (e.g. the article image field in an article context). If my assumption is correct, you don’t need the if_yield at all.

Also, as far as I remember, the tags within the txp:images container don’t need the id attribute to respecified.

And also you can do <txp:smd_thumbnail type="1600" display="url" /> instead of <txp:smd_thumbnail type="1600"><txp:smd_thumbnail_info item="url" /></txp:smd_thumbnail>.

See if this works for you:

<figure class="slide" role="figure" aria-label="caption">
   <txp:images id='<txp:yield name="id" />'>
      <a class="chocolat-image"
          href="<txp:smd_thumbnail type="1600" display="url" />"
          title="<txp:image_info type="alt" />">
         <img src="<txp:smd_thumbnail type="400" display="url" />"
              alt="<txp:smd_thumbnail_info item="alt" />"
              srcset="<txp:smd_thumbnail type="400" display="url" /> 400w,
                      <txp:smd_thumbnail type="800" display="url" /> 800w,
                      <txp:smd_thumbnail type="1200" display="url" /> 1200w"
              sizes="400px" loading="lazy">
      </a>
   </txp:images>
</figure>

Fingers crossed!

—-

I find not specifying an id in the shortcode too unpredictable. In the wrong context it can spit out all the images by an author, or in a category. I prefer to notify the user that they forgot the id attribute, so I wrap the entire shortcode output in if_yield:

<txp:if_yield name="id">
    … tag soup …
<txp:else />
    <p class="error-msg shortcode">Error: Missing <code>id</code> attribute in your <code>txp::figure</code> shortcode.</p>
</txp:if_yield>

TXP Builders – finely-crafted code, design and txp

Offline

#5 2020-02-14 23:29:12

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,152
Website

Re: Txp can't find an openingstag ... !?

jakob wrote #321667:

Another possible option: could you get away with just?

<txp:images id='<txp:yield name="id" />'>...

That is what I’ve used for ages and works great – I can insert one or more images and the whole construction outputs fine.

Good point about doing some error checking.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#6 2020-02-17 07:56:28

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 809
Website

Re: Txp can't find an openingstag ... !?

Thanks to everyone … :)

marijevijselaar.nl/new (still under construction)

<!-- Chocolat (lightbox) -->
<div class="chocolat-parent" data-chocolat-title="">
<div class="slide-container">
<txp:images id='<txp:yield name="id" />'>
<figure class="slide" role="figure" aria-label="caption">
<txp:adi_if_not_mobile><a class="chocolat-image" href='<txp:smd_thumbnail type="1600"><txp:smd_thumbnail_info item="url" /></txp:smd_thumbnail>' title='<txp:image_info type="alt" />'></txp:adi_if_not_mobile>
<img src="<txp:smd_thumbnail type="400"><txp:smd_thumbnail_info item="url" /></txp:smd_thumbnail>" alt='<txp:smd_thumbnail_info item="alt" />' srcset="<txp:smd_thumbnail type="400"><txp:smd_thumbnail_info item="url" /> 400w</txp:smd_thumbnail>, <txp:smd_thumbnail type="800"><txp:smd_thumbnail_info item="url" /> 800w</txp:smd_thumbnail>, <txp:smd_thumbnail type="1200"><txp:smd_thumbnail_info item="url" /> 1200w</txp:smd_thumbnail>" sizes="400px" loading="lazy" /><txp:adi_if_not_mobile></a></txp:adi_if_not_mobile>
</figure>
</txp:images>
</div>
</div>

Offline

Board footer

Powered by FluxBB