Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2020-10-01 08:57:20

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

Re: Authors listings only if more than 1 author exists

etc wrote #326181:

<txp:article_custom pgonly pageby="AuthorID" />...

Fine by me if it’s not too confusing. Anything else makes sense here in pageby while we’re at it? Our current definition is:

pageby=“integer” The number of articles to output per page.

So we’d need to figure out how to reword that accordingly.

Also, what would the result be without pgonly?


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

#12 2020-10-01 09:07:29

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

Re: Authors listings only if more than 1 author exists

Bloke wrote #326182:

Also, what would the result be without pgonly?

Non-numeric pageby and pgonly are not used atm, suggestions welcome. That could be as well

<txp:article_custom pgonly="AuthorID" />

Offline

#13 2020-10-01 09:16:25

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

Re: Authors listings only if more than 1 author exists

Even as it stands, things are a mite confusing. For example:

<txp:article_custom section="articles" limit="20" pageby="8" wraptag="ul" break="li">
   <txp:title />
</txp:article_custom>

Outputs 20 article titles. So what does pageby even do here?


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-10-01 09:21:08

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

Re: Authors listings only if more than 1 author exists

Bloke wrote #326184:

Even as it stands, things are a mite confusing. For example:

<txp:article_custom section="articles" limit="20" pageby="8" wraptag="ul" break="li">...

Outputs 20 article titles. So what does pageby even do here?

That was not me :-) It sets the total number of pages used in pagination tags. Makes sense when you output multiple <txp:article /> tags with offsets. There were some examples in forum.

Offline

#15 2020-10-01 09:30:28

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

Re: Authors listings only if more than 1 author exists

Right, so the definition of pageby on the docs page is a bit misleading then. We should adjust that.

From that view, pageby="AuthorID" is saying ‘set the pagination tags to page by the number of discrete authors that have published articles’ which is kinda nonsense isn’t it? Not sure.

I’d be tempted to go with pgonly="AuthorID" because that currently boolean value toggles on whether to output the number of pages. So we could hijack this quite neatly:

  • pgonly="1" = output the number of article pages
  • pgonly="AuthorID" = output the number of article Authors
  • pgonly="ID" = output the number of articles

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-10-01 09:41:16

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

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: 9,789
Website

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.

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,396
Website

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: 3,940
Website

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: 9,789
Website

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.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB