Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2025-08-06 01:28:00

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

Make the exclude attribute global

According to the documentation the exclude by id attribute works for articles, but not in other lists such as the images, linklist, and file_download_list. It would be cool if the attribute was global to allow a construction like this:

<txp:images category="my_category" limit="8" break="" exclude="377" />

A case where this will be of use is on an article where the image with id 377 which belongs to my_category is the ‘hero’ on the top, and a gallery with the rest of the images further down the article.

In the real world the code could be

<txp:images category="my_category" limit="8" break="" exclude='<txp:custom_field name="article_image" />' />

or even

<txp:images category='<txp:custom_field name="image_category" />' limit="8" break="" exclude='<txp:custom_field name="article_image" />' />

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

Offline

#2 2025-08-06 06:00:21

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,423
Website

Re: Make the exclude attribute global

+10

That would be quite useful.


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

Offline

#3 2025-08-06 10:59:30

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

Re: Make the exclude attribute global

I was just thinking that the exclude attribute also works for section_list and category_list in a non numeric way. Would this complicate my feature request?


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

Offline

#4 2025-08-06 15:24:35

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

Re: Make the exclude attribute global

To be pedantic, exclude can not be global, i.e. applicable to all tags. Adding it to <txp:images /> etc is possible, though I would still prefer to unify different content types in a future txp version, to get it for free.

If only numeric ids are concerned, might we use negative values instead:

<txp:images category="my_category" limit="8" break="" id="-377" />

Offline

#5 2025-08-06 17:30:39

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

Re: Make the exclude attribute global

etc wrote #340074:

To be pedantic, exclude can not be global, i.e. applicable to all tags. Adding it to <txp:images /> etc is possible, though I would still prefer to unify different content types in a future txp version, to get it for free.

If only numeric ids are concerned, might we use negative values instead:

<txp:images category="my_category" limit="8" break="" id="-377" />...

wpould that also work with a comma separated list of ids?

<txp:images category="my_category" limit="8" break="" id="-377,-344" />...


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

Offline

#6 2025-08-06 21:38:31

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

Re: Make the exclude attribute global

colak wrote #340075:

wpould that also work with a comma separated list of ids?

<txp:images category="my_category" limit="8" break="" id="-377,-344" />...

It would, but this is not really handy, so let it be exclude. But we need to decide, which attributes can be ‘excludable’: id for sure, but what about extension, size and so on?

Offline

#7 2025-08-07 03:58:03

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

Re: Make the exclude attribute global

etc wrote #340077:

It would, but this is not really handy,…

Indeed!

… so let it be exclude. But we need to decide, which attributes can be ‘excludable’: id for sure, but what about extension, size and so on?

I can actually think of cases where excluding extension or size would be helpful for some, but I’d also would like to hear what the community thinks.


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

Offline

#8 2025-08-07 04:33:30

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,423
Website

Re: Make the exclude attribute global

I certainly can see a use for ext. size I am not sure

In an ideal world the possibility to exclude based on a CF… Background: I use a jcr_image_custom field to establish a link between the uploaded image an the same image in a different format (e.g. uploaded = jpg, altformat = webp). I might be interested in excluding images from a list when the CF is emptyexclude="<txp:jcr_image_custom name="foo" value="" />". I might be a little greedy with this :-)


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

Offline

#9 2025-08-08 05:37:20

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,423
Website

Re: Make the exclude attribute global

Might (image) category be a candidate for exclusion ?

I can easily see a situation where you want to build an image gallery type object fetching images from various categories but one category should be omitted.


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

Offline

#10 2025-08-08 09:22:11

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

Re: Make the exclude attribute global

phiw13 wrote #340088:

Might (image) category be a candidate for exclusion ?

Category and other core fields is no problem, but excluding plugin-added fields would be tricky.

Offline

#11 2025-08-09 03:17:52

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

Re: Make the exclude attribute global

phiw13 wrote #340088:

Might (image) category be a candidate for exclusion ?

I can easily see a situation where you want to build an image gallery type object fetching images from various categories but one category should be omitted.

Unless I misunderstood your question, image categories can already be excluded. In docs.textpattern.com/tags/category_list:

<txp:category_list label="Image Categories" type="image" exclude="my-category" wraptag="ol" break="li" />

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

Offline

#12 2025-08-09 03:29:52

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,423
Website

Re: Make the exclude attribute global

colak wrote #340091:

Unless I misunderstood your question, image categories can already be excluded.

Yes, but that builds a list of image categories, not a list of images

The point in this thread is adding the exclude attribute to more tags (in this case <txp:images />.

There are various ways todo now what I suggested with category, one of which could be using categrory list in a variable.


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

Offline

Board footer

Powered by FluxBB