Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-05-19 17:30:05

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

[RFC] <txp:search_result_count> : rename?

For some time now the search_result_count tag has done more than count search results. I’ve been refactoring the examples as part of the tags refresh effort and the first example demonstrates its ability quite well.

Since this tag now counts articles – and can do so before or after a corresponding <txp:article> tag – is it about time we renamed it to <txp:article_count />? That would make the example:

<txp:if_search>
    <txp:article_count />
<txp:else />
    <txp:if_article_list>
        <txp:article_count text="articles" />
    </txp:if_article_list>
</txp:if_search>

<txp:article />

Much more logical, since its use inside <txp:if_search> or <txp:if_search_results> is obviously “show how many articles there are in the search results”.

As it stands, calling <txp:search_result_count> outside of a search context seems odd.

Last edited by Bloke (2021-05-19 17:30:55)


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

#2 2021-05-19 19:16:42

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: [RFC] <txp:search_result_count> : rename?

Will be possible to sort search results by the count of matches now? (we were disputed that problem two years ago).

Offline

#3 2021-05-19 19:30:32

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

Re: [RFC] <txp:search_result_count> : rename?

Hmmm, not sure. It’s probably possible by using the new fields attribute in the article tags.

The search_result_count tag simply outputs the number of results found (or live articles in the current section/page) so there’s no sorting to be had here – you can’t sort by a single number as it doesn’t make sense to do so.

It would be good to allow the ‘relevance’ (score) to be used in a better fashion than we have it now, but I can’t remember offhand how it’s calculated. I think it’s up to the SQL query to return it so maybe the way its calculated needs tweaking.


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

#4 2021-05-19 20:19:58

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

Re: [RFC] <txp:search_result_count> : rename?

Hmm, just imagine the number of sites that would be broken if we merely rename it…

Vienuolis wrote #330204:

Will be possible to sort search results by the count of matches now? (we were disputed that problem two years ago).

You can try to sort them as discussed here.

Bloke wrote #330205:

I can’t remember offhand how it’s calculated. I think it’s up to the SQL query to return it so maybe the way its calculated needs tweaking.

IIRC, it uses MATCH AGAINST construction that is pertinent, but for English only, AFAIK.

Offline

#5 2021-05-19 21:04:22

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

Re: [RFC] <txp:search_result_count> : rename?

etc wrote #330207:

just imagine the number of sites that would be broken if we merely rename it…

I didn’t mean immediately, haha. I meant throw a deprecation warning for a few versions and encourage people to migrate.


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

#6 2021-05-20 09:04:20

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

Re: [RFC] <txp:search_result_count> : rename?

Bloke wrote #330210:

I didn’t mean immediately, haha. I meant throw a deprecation warning for a few versions and encourage people to migrate.

Txp dev renders paranoic :-) There is one thing to take into account: this tag pulls its data from the global thispage used also in files, images and links lists. So the name of article_count would be a bit ambiguous. We could introduce some general-purpose items_count tag, perhaps?

Offline

#7 2021-05-20 09:29:03

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

Re: [RFC] <txp:search_result_count> : rename?

etc wrote #330219:

this tag pulls its data from the global thispage used also in files, images and links lists. So the name of article_count would be a bit ambiguous. We could introduce some general-purpose items_count tag, perhaps?

That would be much better, yes. Or just <txp:count /> or <txp:total />? Are those too generic? Probably.

Could the scope of such a tag be expanded to count ‘stuff’? It’ll count the most appropriate thing based on context but a type attribute could override it, perhaps?

No idea if that’s possible. If it is, feel free to dabble!

Last edited by Bloke (2021-05-20 09:32: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

#8 2021-05-20 23:07:49

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,162
Website

Re: [RFC] <txp:search_result_count> : rename?

I would prefer <txp:items_count /> for the clarity of purpose, if I understand the discussion correctly.


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

Offline

#9 2021-05-20 23:42:07

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

Re: [RFC] <txp:search_result_count> : rename?

Noted. <txp:items_count /> is probably best.


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