Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2020-10-01 09:41:16

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

Re: Authors listings only if more than 1 author exists

Bloke wrote #326186:

I’d be tempted to go with pgonly="AuthorID" because that currently boolean value toggles on whether to output the number of pages.

+1, we just need to decide whether it sets pagination data when used in <txp:article /> (not custom). I guess yes, for consistency, though see no usecase for this.

Offline

#17 2020-10-01 09:47:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

Re: Authors listings only if more than 1 author exists

Yeah, uhh, let’s go with consistency. Someone will come up with a use case, I expect :)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#18 2020-10-01 10:09:35

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,566
Website GitHub Mastodon

Re: Authors listings only if more than 1 author exists

If this tag amend can make it into 4.8.4, that would be mighty useful to my theme plans. Cheers all!

Offline

#19 2020-10-01 10:20:00

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

Re: Authors listings only if more than 1 author exists

philwareham wrote #326189:

If this tag amend can make it into 4.8.4, that would be mighty useful to my theme plans. Cheers all!

Leave me half an hour. It looks like 4.8.4 is already behaving sagely on php 8, so we have time for extra bonuses.

Offline

#20 2020-10-01 12:32:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

Re: Authors listings only if more than 1 author exists

That patch is brilliant, Oleg.

Love the way you’ve made it so it can query any column, which gives some great scope for doing crazy things like counting custom fields (at least for now: not sure how we’ll honour that when unlimited CFs land in a separate table, but we’ll worry about that later).

One intriguing side-effect of counting stuff in columns that may be null is that the count is always 1 higher than expected. e.g. pgonly="category1" will return 1 when your category1 is ‘not used’, because ‘uncategorized’ (empty) is still a thing.

Technically that is correct: it should be 1. And empty rows should be counted. But I wonder if there’s some way we could let people choose whether to omit ‘unused’ content from the counts? With my user interface hat on, either trim or escape="trim" or escape="tidy,trim" or even a new one escape="count" makes sense, but that affects output only doesn’t it?

Is there a way to wire something up so it also affects the query in this case? Or is that going to really make things confusing?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#21 2020-10-01 12:41:51

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,566
Website GitHub Mastodon

Re: Authors listings only if more than 1 author exists

Cool! So just to clarify, the code for my OT would be this, yes?…

<txp:article_custom pgonly="AuthorID" />

Offline

#22 2020-10-01 12:43:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

Re: Authors listings only if more than 1 author exists

Yep.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#23 2020-10-01 13:19:39

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

Re: Authors listings only if more than 1 author exists

Bloke wrote #326191:

Is there a way to wire something up so it also affects the query in this case? Or is that going to really make things confusing?

I think (to test) you can filter via category attribute:

<txp:article_custom category pgonly="Category1" />

though it will output an empty string instead of 0 (will fix).

Offline

#24 2020-10-01 13:27:34

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

Re: Authors listings only if more than 1 author exists

etc wrote #326194:

I think (to test) you can filter via category attribute:

Hmmm, I still get the same count out (22 in this case) when I’m expecting 21, excluding the empty row. That’s a neat solution though if it works.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#25 2020-10-01 14:30:43

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

Re: Authors listings only if more than 1 author exists

Bloke wrote #326195:

Hmmm, I still get the same count out (22 in this case) when I’m expecting 21, excluding the empty row.

Well, category translates as (Category1 != '') OR (Category2 != ''), and we count distinct Category1. Is it possible that you have an article with empty Category1 but not empty Category2?

Offline

#26 2020-10-01 14:35:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

Re: Authors listings only if more than 1 author exists

etc wrote #326196:

Is it possible that you have an article with empty Category1 but not empty Category2?

Highly probable.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#27 2020-10-01 14:39:53

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

Re: Authors listings only if more than 1 author exists

Bloke wrote #326197:

Highly probable.

Then you should query for

<txp:article_custom category match="Category1" pgonly="Category1" />

Offline

#28 2020-10-01 15:17:08

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,498
Website GitHub

Re: Authors listings only if more than 1 author exists

Bingo!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#29 2020-10-01 15:18:40

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,566
Website GitHub Mastodon

Re: Authors listings only if more than 1 author exists

I can also confirm the new functionality allows me to enable/disable multi-author features in my theme – so that’s great stuff. Thanks Oleg!

Offline

Board footer

Powered by FluxBB