Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-01-13 15:50:40

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Multiple custom field values in article_custom proposal

Given that the original post can’t be deleted I’ll ask for another feature related with article_custom and customfieldname=“value”.
I learned today that the buildCustomSql() function uses the LIKE operator and this is good so we can write:

<txp:article_custom my_custom_field="%specific_value%" />

… and this will select also articles with a custom field value of “specific_value|another value”.

The issue arises when a cf value is a substring of another value so:

<txp:article_custom my_custom_field="%mens%" />

…will select an article with a cf containing “womens”.

This could be avoided setting values wisely such as “1-mens” and “2-womens” but – I don’t know if this makes sense – what if the buildCustomSql() function was slightly altered so that:

$out[] = "and custom_".$no[0]." like binary '$v'";? (I’ve added binary)

This should make sure (mysql is not my thing) that the query works in a case-sensitive manner, thus allowing to take advantage of cf values capitalization. Now the previous example:

<txp:article_custom my_custom_field="%Mens%" /> (note the capital ‘M’)

…will NOT select an article with a cf containing “Womens”.

P.S. forgive me if I’m telling nonsense.

Hi,
Reading this post I was wondering if it could be possible to enhance the article_custom tag regarding the customfieldname=“value” attribute, so to check for the presence of a specific value in a delimiter separated list.
I think this would require only the addition of a new attribute called “custom_field_delimiter”, which defaults to “|” to avoid issues in case “|” is used for another purpose.
-Of course this would be benefical mainly for those of us using glz_custom_fields but even in a standard txp installation it could be of some use (do you remember sed_pcf

edit Never mind. I just discovered this tip which somehow solves the problem (I can’t delete this post so I added ‘solved’ in the title)

Last edited by redbot (2012-01-13 19:40:26)

Offline

Board footer

Powered by FluxBB