Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-03-07 14:30:33

txpnisti
Member
Registered: 2009-02-25
Posts: 23

Custom fields, related articles by partial match

I know this is propably not possible with built in tools, perhaps some plugin could help…

We save a special phrase in one custom field. How would it be possible to list related articles, where match should be the first word in that custom field? We have already quite lot of articles, and this is now a new need, so manually adding some new triggers into articles would take a year, or something…

Offline

#2 2009-03-07 16:57:27

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,730
Website

Re: Custom fields, related articles by partial match

Actually, you can use txp:article_custom with the attribute customfieldname="value" to restrict output to articles with specified value for specified custom field name. Replace “customfieldname” with the name of your custom field.

If you’re using txp v4.07+ you can also use tags in tags to grab the current value of your custom field using txp:custom_field. If you’re on an earlier version you need to wrap the statement in asy_wondertag.

<txp:article_custom form="my-related-articles" my-custom-field-name='<txp:custom_field name="my-custom-field-name" />' />

This would output all articles with the same value as the specified custom field in the current article. What I’m not sure is if this will also work with just a part of that custom field or if it has to be the whole value for the custom field. For this you might want to try using aam_split_custom_field instead of txp:custom_field in the code above. I’ve not used aam_split_custom_field myself but from the reading the docs it looks like it can chop a custom_field using a separator and extract a portion of it with the help of limit/offset attributes. Whether txp:article_custom will match it successfully, you will have to test.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2009-03-07 20:32:09

txpnisti
Member
Registered: 2009-02-25
Posts: 23

Re: Custom fields, related articles by partial match

Haa, sounds usefull! Have to test, thanks!

Offline

Board footer

Powered by FluxBB