Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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-separatedvenue="1,2"
and a|
-separatedgreeting="Hello, world|Welcome to Textpattern"
, usingmatch="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
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
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
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
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
Re: extend match attribute
etc wrote #302445:
It actually already works like this, with comma:
match="venue1,venue2"
matches the articles with the samevenue1
andvenue2
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
- by author 1
- by author 2
- by author 1 & author 2
- by author 1 and somebody else
- 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
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
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