Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How to exclude articles by url_title partial match
Is there a way to use article_custom
tag to exclude articles based on how url_title
ends? I’d like to exclude those that end with -mobile or -touch.
Offline
Re: How to exclude articles by url_title partial match
Sadly, hiding via <txp:if_custom_field name="url_title" />
seems to be the only option. I remember several discussions on adding url_title
attribute, but for some reason that has not been done yet. Maybe in 4.8.8?
Edit: please test if you can.
Offline
Re: How to exclude articles by url_title partial match
Oh right, etc, thanks. :-) I’ll test smd_query
plugin next.
Offline
Re: How to exclude articles by url_title partial match
Ach, forgot about it. Good catch, etc. That’s a lovely addition… and substring comparisons in the escape
attribute too, woohoo!
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
#5 2021-06-11 12:09:05
- pexman
- Member
- Registered: 2016-02-27
- Posts: 61
Re: How to exclude articles by url_title partial match
Plugin aks_article, <txp:aks_article /> You have the option ‘exclude’, a rewritten core functions extended article_custom tag, author makss
Offline
Re: How to exclude articles by url_title partial match
^ Yes, you’re correct. That’s exactly what did the job. :-) Unfortunately makss’ website is gone, so I had to use an old version of that plugin (0.3.2).
Offline
Re: How to exclude articles by url_title partial match
Bloke wrote #330432:
substring comparisons in the
escape
attribute too, woohoo!
Thanks! Still unsure how to treat negative values: should escape="-3"
applied to abcdefgh
return abcde
, defgh
or fgh
?
pexman wrote #330436:
Plugin aks_article, <txp:aks_article /> a rewritten core functions extended article_custom tag
It might be very out of date now… And out of curiosity, how does one exclude articles by url_title
?
Offline
Re: How to exclude articles by url_title partial match
etc wrote #330438:
Still unsure how to treat negative values: should
escape="-3"
applied toabcdefgh
returnabcde
,defgh
orfgh
?
Yeah, tricky. Without the concept of ‘length’, the offset itself is always going to be anchored to either end of the string, so for consistency I would go with fgh
, which mirrors PHP’s implementation.
- A positive value crops N characters after the given number and returns the string from the start up until that point. i.e. the first N characters.
- A negative value crops N character before the given number, as counted from the end of the string, and return the string from that point up until the end of the string. i.e. the last N characters.
That seems 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
Re: How to exclude articles by url_title partial match
Bloke wrote #330439:
That seems logical to me.
I agree on escape="+n"
returning the first n
characters, seems useful. But is there any use for the last n
characters? I’d rather vote for defgh
, so one could easily split strings.
Sorry for hijacking the thread.
Offline
Re: How to exclude articles by url_title partial match
defgh
can be obtained by escape="-5"
:)
But yeah, I see what you mean. Okay, maybe my first example was wrong above. With input abcdefgh
how about this concept instead:
escape="+4"
: defghescape="-3"
: fghescape="+4..2"
: deescape="-3..2"
: fg
So +/-offset..length
instead (with a two- or three-dot delimiter, or another delimiter of choice), counting from 1/-1 from each end. That differs from PHP, which starts at 0 from the start and -1 from the end, but I think that’s confusing.
Without the length, you get ‘to the end of the string’ returned.
Does that work for sub-splitting, or does it conflict with other escape
values? Or are there corner cases that it doesn’t catch?
Last edited by Bloke (2021-06-11 13:12:03)
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
Re: How to exclude articles by url_title partial match
Another wildcard… is this more closely aligned with trim
than escape
? e.g. given https://example.org/section/article
as input:
trim="+20"
: /section/articletrim="+20" replace="https://example.com"
: https://example.com/section/article
?? Being able to pair it with replace
seems kinda desirable.
EDIT: fix idiocy.
Last edited by Bloke (2021-06-11 13:20:03)
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
Re: How to exclude articles by url_title partial match
Bloke wrote #330441:
So
+/-offset..length
instead
Nice idea, especially since we already use these dotted notations for ranges in id
and other attributes. Should be doable.
Bloke wrote #330442:
Another wildcard… is this more closely aligned with
trim
thanescape
?
Probably, but trim
can already handle regex, so this wouldn’t add much value.
Offline