Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2011-03-04 20:39:18

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: soo_article_filter: additional control over article lists

Looks like it would be easy to add the needed code. The question is whether or not this is really practical with regard to performance and database usage, particularly for low-budget shared hosting. I may be able to look at it this weekend.


Code is topiary

Offline

#38 2011-03-04 20:46:34

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,214
Website

Re: soo_article_filter: additional control over article lists

wow, just came aross this plugin which would have been a good fit for a dilemma I just solved. jsoo: Off the top of your head can you think of a way to attack the challenge of grouping articles into one issue for the purposes of a newsletter?

Offline

#39 2011-04-29 22:10:17

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

Re: soo_article_filter: additional control over article lists

Jeff, in the docs you show that it’s possible to search for all articles where a custom field includes a string with soo_article_filter:

<txp:soo_article_filter my-custom-field="blue">
<txp:article />
</txp:soo_article_filter>

… or even without it:

<txp:article_custom my-custom-field="%blue%" />

… noting that this will also match “Blues” or “true blue”, etc. That’s great for extracting a value from one of several values in a custom field, for example when it’s a comma-separated list.

But what if the custom_field contains some combination of the following as a comma-separated list: janet,fred,jo,jane,john? An article_custom or soo_article_filter for “jane” will also find all articles with “janet”, similarly filtering against “jo” will also find all those with “john”.
Another typical situation might be a custom field containing 1,3,23,31,52 where the problem is even more extreme: filtering against “3” also gives you those articles with “23” and “31” in the custom_field.

Is it possible to use soo_article_filter to make it more exacting? I have a feeling the where attribute could help, but how could I make it find an explicit value in a series of comma-separated items in a custom_field? Any pointers much appreciated.


TXP Builders – finely-crafted code, design and txp

Offline

#40 2011-04-30 00:15:44

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: soo_article_filter: additional control over article lists

jakob wrote:

JBut what if the custom_field contains some combination of the following as a comma-separated list: janet,fred,jo,jane,john? An article_custom or soo_article_filter for “jane” will also find all articles with “janet”, similarly filtering against “jo” will also find all those with “john”.

Not quite. On custom fields, soo_article_filter uses the MySQL REGEXP operator; article_custom uses the MySQL LIKE operator. So, in your example, using “jane” as the attribute value, soo_article_filter will indeed match “janet”, but article_custom will not (unless you add the wildcard character).

However, matching exact values in a comma-separated list is a different problem. You can solve that using the MySQL regex word boundary markers: [[:<:]] for the start of a word, and [[:>:]] for the end of a word. So, e.g.,

soo_article_filter some_custom_field="[[:<]]jane[[:>:]]"

would match “jane” but not “janet” in a comma-separated list.

soo_article_filter some_custom_field="jane[[:>:]]"

would match “maryjane” and “jane”, but still not “janet”.


Code is topiary

Offline

#41 2011-04-30 23:07:39

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

Re: soo_article_filter: additional control over article lists

Thank you Jeff. That’s most helpful and informative!

I tried out article_custom some_custom_field="jane" and it only finds entries that contain only “jane” in the custom_field and not those that contain “jane,fred”. If I use article_custom some_custom_field="%jane%" it finds both cases but one runs into the problem described above if the name/term is not sufficiently unique.

I’ll give it a go with soo_article_filter and the word boundary regex. That looks promising!


TXP Builders – finely-crafted code, design and txp

Offline

#42 2013-12-19 21:25:08

dorka
Member
Registered: 2012-10-04
Posts: 90

Re: soo_article_filter: additional control over article lists

Hi Jeff,
I used your plugin in a very basic way:

<txp:soo_article_filter Velikost="116">
                     <txp:article_custom section="<txp:section/>" category="<txp:category />" form="model-v-katalogu-vel" pgonly="0" status="4"  limit="12"/>
                  </txp:soo_article_filter>

but it doesn’t seem to do anything – the resulting list of articles is identical with the unfiltered list.

I use glz_custom_fields plugin to add extra functionaity to the my custom fields. In this case the custom field “Velikost” is defined as dropdown list of values. Could this be the problem or am I realy dumb and can’t see an obvious mistake in my code?
Thanks

Offline

#43 2013-12-19 21:29:14

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,259

Re: soo_article_filter: additional control over article lists

dorka wrote #277459:

but it doesn’t seem to do anything

Dorka, use single quotes whenever you place a TXP tag as a value of a TXP attribute, i.e.

<txp:article_custom section='<txp:section/>' category='<txp:category />' form="model-v-katalogu-vel" limit="12"/>

Edit: You don’t need pgonly="0" status="4", the first one is only for txp:article, the second one is default.

Last edited by uli (2013-12-19 21:39:44)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#44 2013-12-19 21:41:25

dorka
Member
Registered: 2012-10-04
Posts: 90

Re: soo_article_filter: additional control over article lists

Hey Uli, my guarding angel :-),
thank you, I fixed this, but it didn’t fix the filter result.

Offline

#45 2013-12-19 22:00:00

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,467

Re: soo_article_filter: additional control over article lists

For your use, you don’t need this plugin. You can do the same with:

<txp:article_custom section='<txp:section/>' category='<txp:category />' Velikost="116" form="model-v-katalogu-vel" limit="12"/>

See txp:article_custom.

Offline

#46 2013-12-19 22:00:50

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,259

Re: soo_article_filter: additional control over article lists

“116” is defined as one of the menu items of the dropdown you’ve created for your custom_field Velikost?

Edit: I assume GugUser is one step closer.

Last edited by uli (2013-12-19 22:02:44)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#47 2013-12-19 22:01:56

dorka
Member
Registered: 2012-10-04
Posts: 90

Re: soo_article_filter: additional control over article lists

that is correct

Offline

#48 2013-12-19 22:17:46

dorka
Member
Registered: 2012-10-04
Posts: 90

Re: soo_article_filter: additional control over article lists

For your use, you don’t need this plugin. You can do the same with:

Oh, hm, I guess you’re right….

Any way as I’m playing around with the code I realize, that the plugin works allright. There must be a mistake in my form, or something. Guys, sorry for the trouble, I think I shoudl give it another try by myself. (Gosh, I’ve alredy spent days on this!!!)

Offline

Board footer

Powered by FluxBB