Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-10-24 06:27:16

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

extend match attribute

Following the acrobatics to get links to related content in this thread, a feature request is due for the next txp version.

As Oleg kindly pointed out to me txp has indeed made some steps in the right direction such as <txp:related_articles match="venue" limit="30" break="," wraptag="" />. What happens though when the custom field (in this case named venue) has more than one value?

The request is to add a matchseparator attribute so as to allow those with sightly more complex sites to match both values. the resulting tag could look like:

<txp:related_articles match="venue" matchseparator=","  limit="30" break="," wraptag="" />

matchseparator could have its default value to NONE for backward compatibility. When the custom field value only has one value, the separator attribute should be ignored.


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 2016-10-24 09:37:43

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

Re: extend match attribute

I agree that’s a legitimate request, but the proposed implementation wouldn’t be ideal. Just because match attribute accepts multiple fields (Category1,Category2 by default), and different custom fields can use different separators. So, if you had a comma-separated venue="1,2" and a |-separated greeting="Hello, world|Welcome to Textpattern", using match="venue,greeting" matchseparator="," would be problematic.

A possible solution is to make separator part of custom fields definition, but this would be postponed to unlimited custom fields era (currently 4.8?)…

Offline

#3 2016-10-24 09:47:47

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

Re: extend match attribute

etc wrote #302430:

I agree that’s a legitimate request, but the proposed implementation wouldn’t be ideal. Just because match attribute accepts multiple fields (Category1,Category2 by default), and different custom fields can use different separators. So, if you had a comma-separated venue="1,2" and a |-separated greeting="Hello, world|Welcome to Textpattern", using match="venue,greeting" matchseparator="," would be problematic.

agree

A possible solution is to make separator part of custom fields definition,

good idea!!!

but this would be postponed to unlimited custom fields era (currently 4.8?)…

I was hoping that we could get those in 4.7 !!!

but… Once we have unlimited custom fields we may no longer need the separator as we will be able to create as many as we need.


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 2016-10-24 09:56:22

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

Re: extend match attribute

colak wrote #302431:

I was hoping that we could get those in 4.7 !!!

No worries, txp roadmap is very… flexible :-)

but… Once we have unlimited custom fields we may no longer need the separator as we will be able to create as many as we need.

Not sure, venue="1,2" is more easily extendible than venue1="1", venue2="2", since not every article has two venues.

Offline

#5 2016-10-24 10:13:20

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

Re: extend match attribute

I was thinking something in the lines of

<txp:related_articles match="venue1,venue2,venue#"  limit="30" break="," wraptag="" />

where venue1, venue2, venue# are separate custom fields.


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 2016-10-24 10:48:28

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

Re: extend match attribute

Another idea could be

<txp:related_articles match="venue1&venue2&venue#"  limit="30" break="," wraptag="" />

to match ALL fields.


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

Offline

#7 2016-10-24 17:49:15

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

Re: extend match attribute

colak wrote #302434:

Another idea could be

<txp:related_articles match="venue1&venue2&venue#" limit="30" break="," wraptag="" />...

to match ALL fields.

It actually already works like this, with comma: match="venue1,venue2" matches the articles with the same venue1 and venue2 that the current one. Or have I misunderstood your idea?

Offline

#8 2016-10-24 18:19:25

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

Re: extend match attribute

etc wrote #302445:

It actually already works like this, with comma: match="venue1,venue2" matches the articles with the same venue1 and venue2 that the current one. Or have I misunderstood your idea?

I guess we should have an option to match either variable or both. I might be thinking about it wrongly but when unlimited custom fields come, some people would be using them to relate articles.

I started writing a rave here but as you kindly helped me with the previous issue, I deleted it as the problem is explained there.

for example.

One could be on a two author text and related articles could be

  1. by author 1
  2. by author 2
  3. by author 1 & author 2
  4. by author 1 and somebody else
  5. by author 2 and somebody else

It would be nice if there was a way to much any of the 5 options which is what I understand your code does. Thanks so much for the explanation by the way. It was wonderfully clear.

What happens though if someone wants to get articles co-written by BOTH author 1 & author 2

For my usage the option seems beyond the scope of what we are trying to do with our website but for a commercial site such as a cars sales, or even for a literary site about books those choices might be important.


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

Offline

#9 2016-10-24 20:42:33

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

Re: extend match attribute

I can’t see a general solution, I’m afraid. What means “BOTH author 1 & author 2”, for example? Of course, if each article has exactly two authors, this makes sense, but it is not always the case. Say, the first article was written by a,c, and the second one by a,b,c. Who is author 1 and author 2? Should these articles match or not?

Edit: ignore me, I see what you mean now.

Last edited by etc (2016-10-24 21:42:35)

Offline

#10 2016-10-25 15:58:06

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

Re: extend match attribute

Okay, here is something. You can call

<txp:related_articles match="venue[]" />

to output the articles having some common venue with the current one. You can even ask for more:

<txp:related_articles match="venue[0]" />

will output the articles that have no common venue with the current one, and

<txp:related_articles match="venue[1|2],venue[-4]" />

will output the articles that CONTAINS(venue1 OR venue2) AND NOT CONTAINS(venue4) of the current one. This is far from being definitive, but should work. Please test and share your remarks.

Edit: currently works only with comma-separated custom fields.

Last edited by etc (2016-10-25 23:10:31)

Offline

Board footer

Powered by FluxBB