Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2023-03-07 08:58:16

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

Re: If related articles

etc wrote #334934:

Both (int) cast and intval() function return 0 afaik.

So if that’s the case and any non-numeric input or empty input results in 0, maybe we should do the same when escaping to int?


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 2023-03-07 10:04:48

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

Re: If related articles

Bloke wrote #334935:

So if that’s the case and any non-numeric input or empty input results in 0, maybe we should do the same when escaping to int?

That’s what we do, and I think it’s all right. The question is whether empty strings should be removed before escaping? If yes, we loose the possibility to transform empty strings to numeric 0. If no, empty strings will be wrapped, unless trim is set. I guess we could trim empty strings by default, unless escape is set:

<txp:hide process="1" wraptag="b"></txp:hide> <!-- outputs nothing -->
<txp:hide process="1" wraptag="b" escape="integer"></txp:hide> <!-- outputs <b>0</b> -->

If one wants to remove empty strings before escaping, he can explicitly set trim:

<txp:hide process="1" trim wraptag="b" escape="integer"></txp:hide> <!-- outputs nothing -->

Offline

#15 2023-03-07 10:36:00

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

Re: If related articles

That sounds pretty darn logical to me.


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 2023-03-07 18:39:36

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

Re: If related articles

Ok, let’s test this plan.

Offline

#17 2023-07-22 21:27:22

agovella
Member
From: Houston, TX
Registered: 2005-05-01
Posts: 66
Website Twitter

Re: If related articles

Tried, unsuccessfully, to follow the thread, so…

First, thank you for related_articles. I must’ve missed this hitting the tags, and it’s pretty boss.

Second, os if_related_articles coming in 4.9? (Is that what the above chat meant?)

Offline

#18 2023-07-22 22:29:06

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

Re: If related articles

agovella wrote #335581:

is if_related_articles coming in 4.9?

No plans to do so. But you can now use txp:evaluate as mentioned above to test for it, in a cleaner manner under 4.9.


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

Board footer

Powered by FluxBB