Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2019-04-18 12:33:26

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

Re: Can I narrow searches to only articles with certain tags?

In some plugins I use 4.5..4.7 to say “between 4.5 and 4.7”. I don’t think someone ever needs to search for .. in a custom field, so we could adopt it in core. In your case we could use min-version and max-version cf and transform target=4.6 query into

min-version='..<txp:page_url type="target" />'
    max-version='<txp:page_url type="target" />..'

Offline

#14 2019-04-18 12:47:09

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

Re: Can I narrow searches to only articles with certain tags?

Ok that sounds good. And if max-version is blank then it assumes that plugin is still compatible (no max version limit).

Offline

#15 2019-04-18 13:40:44

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

Re: Can I narrow searches to only articles with certain tags?

What happens if somebody has an older install? Will links to previous versions of plugins be available?


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

Offline

#16 2019-04-18 14:09:21

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

Re: Can I narrow searches to only articles with certain tags?

colak wrote #317688:

What happens if somebody has an older install? Will links to previous versions of plugins be available?

Hopefully, yes. Not got that far into the developments yet but should be.

Offline

#17 2019-06-10 21:16:46

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

Re: Can I narrow searches to only articles with certain tags?

etc wrote #317685:

In some plugins I use 4.5..4.7 to say “between 4.5 and 4.7”.

Now in dev you can try 4.5%%4.7 (between 4.5 and 4.7) or 4.5%% (since 4.5). The double percent %% syntax is otherwise useless in db LIKE queries anyway.

Offline

#18 2019-06-25 14:54:24

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

Re: Can I narrow searches to only articles with certain tags?

Hi, I’m back to looking at this now. So, where I’m at:

I’ve created a custom field called compatibility and for each article I’ll use your suggested values such as 4.5%% and 4.5%%4.7 as mentioned above (I’m using Textpattern 4.8-dev).

I need two uses for this custom field entry:

Use 1

To display a list of Textpattern versions that an article (plugin) is compatible with. The version numbers are stored in a file-type category list for ease of reference and not assigned to the article directly. So I could list them like so…

<txp:category_list type="file" parent="txp-version" exclude="txp-version" sort="name desc" break=",">
    <span class="compatibility"><txp:category title /></span>
</txp:category_list>

…which would obviously list all the catagories at the moment, which are 4.4, 4.5, 4.6 and 4.7.

So I need a way to only show certain categories from that list if the article’s compatibility custom field is set to 4.6%% or 4.4%%4.5 or 4.7 or whatever. Can you show me some code that can do that filtering?

Use 2

As per my original topic. I need to show, in search results, articles based on what their compatibility custom field is set to. For example, the plugin article ‘etc_cache’ has it’s compatibility custom field set to 4.6%% (since 4.6) so I’d expect the following query to definitely give a search result, but it doesn’t:

bc.
http://www.textpattern-plugins.local/?q=etc_cache&compatibility=4.7

Here’s the article list tag I’m using in search results, that I have tried to decipher from Oleg’s code suggestions so far:

<txp:article compatibility='<txp:page_url type="compatibility" wraptag="%" />' searchform="article_listing" limit="12" />

I assume something is wrong in there?

Sorry, I’ve tried to explain this as best I can! Any help greatly appreciated.

Offline

#19 2019-06-25 17:10:21

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

Re: Can I narrow searches to only articles with certain tags?

Hi Phil,

the double percent %% is not meant to be used in custom fields values but as <txp:article /> filters. For example, if an article’s something cf is set to 4.6, then this article could be retrieved with

<txp:article something="4.4%%4.7" />
<!-- or -->
<txp:article something="4.5%%" />

Now, in plugins site case, we could use two custom fields, say min and max, to store the minimal and the maximal txp versions compatible with a given plugin (article). Say, for etc_cache that would be 4.6 and (currently) 4.7.3.

So, instead of displaying a list of txp versions (categories) compatible with a given plugin, you would display the min and the max versions.

Inversely, to search for all plugns compatibles with a given txp version, you could then try

<txp:article min='%%<txp:page_url type="compatibility" />'
    max='<txp:page_url type="compatibility" />%%' />

The main inconvenience is the necessity to set max value for each article and eventually modify it when a new txp version is released, but, as you say, we’ll have to check plugins compatibility anyway.

Offline

#20 2020-07-02 16:26:21

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

Re: Can I narrow searches to only articles with certain tags?

I’ve finally implanted this code (can’t believe it was a year ago we had this conversation)!

The search works now when custom fields is set, for reference I’m using custom fields:

min-txp-version-verified
max-txp-version-verified

And I have this in my search results code:

<txp:article
    min-txp-version-verified='%%<txp:page_url type="compatibility" />'
    max-txp-version-verified='<txp:page_url type="compatibility" />%%'
    searchform="article_listing" limit="12" />

That allows us to omit results like min-txp-version-verified when the CF value is 4.8 and the compatibility set in the search is 4.7.

However I’ve realised I need to allow results to also appear if custom fields are unset (i.e. the version is unverified at the moment). The above code only seems to allow results if one or both of those custom fields have values – not if they are both blank (I get no results).

Offline

#21 2020-07-03 06:26:40

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

Re: Can I narrow searches to only articles with certain tags?

philwareham wrote #324209:

However I’ve realised I need to allow results to also appear if custom fields are unset (i.e. the version is unverified at the moment). The above code only seems to allow results if one or both of those custom fields have values – not if they are both blank (I get no results).

I don’t think there is a general consensus on whether unset > 4.7 or not, so it would be risky to interpret it in core. We need some other syntax to say or unset.

Offline

Board footer

Powered by FluxBB