Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2020-06-02 16:24:20

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 218
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

Yes, the caption is returned to figcaption, while name="caption" is included in txp:if_yield — thank you, Stef!

Offline

#12 2020-06-02 18:04:14

etc
Developer
Registered: 2010-11-11
Posts: 3,696
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

What a buffoon I am! Line 534 of taghandlers.php should be

$yield[] = isset($thing) ? array($thing) : null;

There is no other way to fix it. I truly apologize.. :-(

Offline

#13 2020-06-02 18:14:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,469
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

etc wrote #323507:

What a buffoon I am!

Haha! Don’t worry about it, and thanks for fixing it. My fault for mentioning the feature and not testing it thoroughly enough.

There’s a workaround for now, but we could squeeze 4.8.2 out in a week or two to patch this and anything else we spot. Won’t affect 4.9 work as that’s got its own branch (dev).

EDIT: though, annoyingly, when merging from 4.8.2 to dev, it pulls the version numbers from 4.8.2 and overwrites the dev ones. So with each merge we need to manually readjust textpattern/textpattern.js, textpattern/index.php and package.json. No biggie. Just something to be aware of. Quite why git thinks 4.9.0 is greater than 4.8.2 and splats the higher values instead of creating merge conflicts or figuring it out, I’m not sure. Maybe it’s a bug and I need to upgrade my local git environment. I’m running 2.8.1, which is way out of date.

Last edited by Bloke (2020-06-02 18:48:56)


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

#14 2020-06-23 10:22:02

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 270
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

Updated three sites from 4.8.0 to 4.8.1 without any problem yet.

PHP version: 7.3.19-1+0~20200612.60+debian8~1.gbp6c8fe1
GD Graphics Library: 2.2.5; Supported formats: GIF, JPEG, PNG, WebP.
MySQL: 5.5.5-10.2.32-MariaDB-10.2.32+maria~jessie-log
Web server: nginx/1.16.1

Offline

#15 2020-06-23 10:25:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,469
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

Brilliant, thanks @whocarez.

4.8.2 is shaping up nicely for imminent release too. Just mops up a few little issues we discovered, tweaks a couple of tags and enhances some stuff for a smoother ride with international users (see forum.textpattern.com/viewtopic.php?id=50806).


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

#16 2020-06-23 15:34:53

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 270
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

Updated the fourth site, which uses the tru_tags plugin and the problem described here is IMHO solved.

But I recognized another problem.

I used to build my own hover title for article lists with the following line:

<txp:php>echo htmlspecialchars_decode(html_entity_decode(trim(strip_tags(category1(array('title'=>'1')) . ": " . title(array("no_widow"=>"0")) . " - " . excerpt())), ENT_HTML5));</txp:php>

Somehow category1 is not usable. I got an "Call to undefined function category1" error.

If I use category1 directly, I’ll get at least one category with "&amp;" in hover title and that’s not really beautiful.

Last edited by whocarez (2020-06-23 15:42:35)

Offline

#17 2020-06-23 15:59:51

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,469
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

whocarez wrote #323947:

category1 is not usable. I got an "Call to undefined function category1" error.

Yes, that function is no more, and this unfortunately highlights the dangers of relying on PHP function calls as we gradually move away from a function-based to OO core.

The slightly more future-proof way of doing it (assuming we keep parse() around!) is:

<txp:php>
echo htmlspecialchars_decode(
    html_entity_decode(
        trim(
            strip_tags(
                parse('<txp:category1 title />: <txp:title no_widow="0" />  - <txp:excerpt />')
            ))
    , ENT_HTML5)
);
</txp:php>

or even (untested) since we have escape attributes that can do strip_tags() and trim():

<txp:php>
echo htmlspecialchars_decode(
    html_entity_decode(
        parse('<txp:category1 title escape="tidy,tags" />: <txp:title no_widow="0"  escape="tidy,tags" />  - <txp:excerpt escape="tidy,tags" />')
    , ENT_HTML5)
);
</txp:php>

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

#18 2020-06-23 16:08:02

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 270
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

Thanks for your quick response. Both variants are working. So I have to go through the old code and “modernize” direct php calls.

Offline

#19 2020-06-23 16:22:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,469
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

whocarez wrote #323949:

So I have to go through the old code and “modernize” direct php calls.

Yes, unfortunately. General rule of thumb is that if you’re using any Txp public tags as function calls, replace them with a call to parse() and pass a string of actual tags into it.

Another option, which is even more future proof might be to create a shortcode:

  1. (optional) Register a new Form type called something like ‘shortcode’ so you can collect all of the codes together in your own group.
  2. Write your tag template / HTML / PHP code in a Form. Name it (e.g. ‘hover’).
    1. Use <txp:yield name="some_att" default="default value" /> to get access to attributes passed into the shortcode.
    2. Use <txp:yield /> to get access to the container (note: you’ll need 4.8.2 for this as there’s a bug in 4.8.1 related to this).
    3. Use <txp:yield else /> to get access to the ‘false’ part of any container tag.
  3. In your article or template code, call your new function: <txp::hover />. Note the double colon. If you elected to use attributes, pass them in too: <txp::hover some_att="my value" />.

Thus, any time you need to make such a change in future or want to expand the scope of your function, you can just do it once in your shortcode.

P.S. smd_where_used might be able to help you find all instances of where you’ve used your code :)

Last edited by Bloke (2020-06-23 16:25:56)


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

#20 2020-06-24 09:29:27

etc
Developer
Registered: 2010-11-11
Posts: 3,696
Website

Re: Feedback to: Textpattern CMS 4.8.1 Released

whocarez wrote #323947:

Somehow category1 is not usable. I got an "Call to undefined function category1" error.

You also should be able to replace category1(...) with

Txp::get('\Textpattern\Tag\Registry')->process('category1', ...)

Offline

Board footer

Powered by FluxBB