Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-02-11 11:15:38

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

figcaption - searchable by default

Thanks devs for deploying <txp::figure />, I am using it always, even for pure text figures.

Unfortunately, the visible live text of an article from figcaption is not searchable — would it not to be included by default?

Offline

#2 2020-02-11 12:09:31

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: figcaption - searchable by default

I would think that this has to do with performance. It is for this reason, I have adapted that code to

<txp:if_yield name="caption">
<figure<txp:if_yield name="class"> class="<txp:yield name="class" />"</txp:if_yield>>
<txp:image id='<txp:yield name="id" />' />
<figcaption class="caption"><txp:yield name="caption" escape="tidy,textile" /></figcaption>
</figure>
<txp:else />
<txp:image id='<txp:yield name="id" />'<txp:if_yield name="class"> class='<txp:yield name="class" />'</txp:if_yield> />
</txp:if_yield>

and call it using

<txp::figure id="#" caption="some caption" class="some classes" />

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2020-02-11 12:40:19

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

Re: figcaption - searchable by default

Thank you very much!

I also forgot the ability to replace an image’s caption with the same custom one by including such attribute of <txp::figure caption="" /> at very important occasions.

Links to pages with a matching query are included in search results now without citation, though.

Offline

#4 2020-02-11 14:55:20

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: figcaption - searchable by default

Vienuolis wrote #321623:

Links to pages with a matching query are included in search results now without citation, though.

Bug? I don’t know. What did our devs intent for this?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2020-02-11 16:42:21

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: figcaption - searchable by default

colak wrote #321624:

Bug? I don’t know. What did our devs intent for this?

As I get it, all tags are stripped before extracting search excerpts, including the attributes of

<txp::figure id="#" caption="some caption" class="some classes" />

You can try to pass captions as content instead:

<txp::figure id="#" class="some classes">
    some caption
</txp::figure>

This will require some snippet modifications (4.8-style):

<txp:if_yield>
    <figure<txp:if_yield name="class"> class="<txp:yield name="class" />"</txp:if_yield>>
        <txp:image yield="id" />
        <figcaption class="caption"><txp:yield escape="tidy,textile" /></figcaption>
    </figure>
<txp:else />
    <txp:image yield="id, class" />
</txp:if_yield>

Offline

#6 2020-02-11 20:09:14

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: figcaption - searchable by default

etc wrote #321625:

This will require some snippet modifications (4.8-style):

Now you tell me:) I’ll check how many instances I have before I change the snippet. Your solution is actually much more readable.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2020-02-12 08:34:01

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

Re: figcaption - searchable by default

What the clear code poetry! Sorry, I am still plowing with the old legitimate Textpattern 4.7.3ω — nothing critical, will wait for the final release of TxP 4.8… Thank you very much!

Offline

#8 2020-02-25 17:45:57

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

Re: figcaption - searchable by default

I have upgraded Textpattern to the new version 4.8.0 successfully, and then replaced this form for <txp::figure />, with some failure: only images <txp::figure> described </txp::figure> in such manner are enclosed by <figure> and <figcaption> tags — all the others are presented by <img> tags only. I am trying to understand what the plain condition <txp:if_yield> means…

Offline

#9 2020-02-25 17:56:19

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

Re: figcaption - searchable by default

Vienuolis wrote #321908:

I am trying to understand what the plain condition <txp:if_yield> means

In this example, the <txp:if_yield> simply asks “is there any content passed to the form in the <txp:output_form>...</txp:output_form> container?”

If there is, the figure/figcaption is shown. Otherwise, a plain image.


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

#10 2020-02-25 17:56:49

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: figcaption - searchable by default

I guess you are asking about Oleg’s recommendation, above.

The way I understand it is that it refers to <figcaption class="caption"><txp:yield escape="tidy,textile" /></figcaption> ie, if caption does not exist, fall back to the img tag.

Stef was faster but he has a different interpretation.

Last edited by colak (2020-02-25 17:58:01)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#11 2020-02-25 18:30:47

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

Re: figcaption - searchable by default

This code seems to work for me so far — is it valid?

 	<figure<if::yield name="class"> class="<txp:yield name='class' />"</if::yield>>
<txp:image yield="id, class" />
		<txp:if_yield>
<figcaption><txp:yield escape="tidy,textile" /></figcaption>
		<txp:else />
<txp:image_info yield="id" escape="tidy,textile" wraptag="figcaption" />
		</txp:if_yield>
	</figure>

Edited: tidy breaks Textile URL quoting.
Edit 2: replaced ‹figcaption› by the same more robust wraptag.
Edit 3: pardon, tidy is innocent, it was my fault — the space is necessary after URL.

Last edited by Vienuolis (2020-02-27 21:06:34)

Offline

Board footer

Powered by FluxBB