Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-11-04 20:09:49
- vurt
- Member
- Registered: 2010-10-22
- Posts: 50
Display 5 most recent articles with same custom field value
I’m looking for a way to display the 5 most recent articles that have a particular custom field value. These articles may not be sequential.
I can do it if there is no limit to the number of articles displayed, but of course then if the limit is large, it will display everything in the range with the same custom field value, and if it’s too small it may not catch all 5.
Last edited by vurt (2010-11-04 20:27:50)
Offline
#2 2010-11-04 20:42:57
- vurt
- Member
- Registered: 2010-10-22
- Posts: 50
Re: Display 5 most recent articles with same custom field value
<txp:article sort="custom_n desc" limit="5" />
Last edited by vurt (2010-11-04 20:43:24)
Offline
#3 2010-11-04 22:23:21
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Display 5 most recent articles with same custom field value
Offline
#4 2010-11-05 12:47:33
- vurt
- Member
- Registered: 2010-10-22
- Posts: 50
Re: Display 5 most recent articles with same custom field value
Thanks Els.
Yes I tried this but, and should have prefaced, I’m using a combination of glz_custom_fields and bot_cf_titles.
No matter what combination of field call I used I couldn’t get it to display anything. Sorting by custom_n worked.
Offline
#5 2010-11-05 15:31:34
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,313
Re: Display 5 most recent articles with same custom field value
bot_cf_titles
Is your custom field name one word or is it interrupted by a blank? Does it use uppercase letters? Neither blanks nor uppercase can be used in custom field names if you want to restrict article calls by custom field names.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Display 5 most recent articles with same custom field value
depending on your version (if oldish)of glz you might need to use:
<txp:glz_article_custom customfieldname="value" limit="5" />
Offline
#7 2010-11-05 15:37:44
- vurt
- Member
- Registered: 2010-10-22
- Posts: 50
Re: Display 5 most recent articles with same custom field value
Yes, it contains both uppercase and space, for the benefit of the client.
I thought that bot_cf_titles would enable me to use the designated replacement, i.e. “custom-n”, to call the field. Perhaps I’m using it in the wrong context.
Offline
#8 2010-11-05 15:44:12
- vurt
- Member
- Registered: 2010-10-22
- Posts: 50
Re: Display 5 most recent articles with same custom field value
mrdale wrote:
depending on your version (if oldish)of glz you might need to use:
<txp:glz_article_custom customfieldname="value" limit="5" />
Using the most recent version of glz 1.2.4., and replacing “Custom Field” in bot_cf_titles with “custom-n” so thinking it would be <txp:article custom-n="value" limit="5" />
?
Offline
#9 2010-11-05 16:04:03
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,313
Re: Display 5 most recent articles with same custom field value
Sorry, I was a tad misleading because of a fault I once did myself. To clarify the confusion I created: It should be
<txp:article your_custom_field_name="value" limit="5" />
or
<txp:article your-custom-field-name="value" limit="5" />
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#10 2010-11-05 16:04:48
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Display 5 most recent articles with same custom field value
vurt wrote:
Yes, it contains both uppercase and space, for the benefit of the client.
I thought that bot_cf_titles would enable me to use the designated replacement, i.e. “custom-n”, to call the field. Perhaps I’m using it in the wrong context.
Hi vurt,
yes the plugin does just this,
the error you are making is that bot_cf_titles operates only – and by purpose – on a presentational level.
In other words you still have to use the cf real name with article_custom.
Last edited by redbot (2010-11-05 16:05:54)
Offline
#11 2010-11-05 16:41:20
- vurt
- Member
- Registered: 2010-10-22
- Posts: 50
Re: Display 5 most recent articles with same custom field value
Okay. Thanks redbot for the clarification on the use of the plugin. I’m using it in an article form as a conditional, <txp:if_custom_field name="Custom Field" val="Value"> etc.
.
Still in the context of a page, unable to call the field using uli’s suggestion above of:
<txp:article your_custom_field_name="value" limit="5" />
or
<txp:article your-custom-field-name="value" limit="5" />
Calling your_custom_field_name=“value” returns 1 article and yields Tag error: <txp:article_custom my_custom_field_name="value" limit="5" form="my_form" section="section1,section2" category="category1,category2" /> -> Textpattern Notice: Unknown tag attribute: my_custom_field_name on line 699
And calling your-custom-field-name=“value” is outputting nothing at all.
Yet, when I use <txp:article sort="custom_n desc" limit="5" />
I get exactly what I need. It appears that sorting by txp’s field assignment works. I should also note that either article or article_custom works exactly the same way, but I need to parse categories so I’m using article_custom.
Offline
#12 2010-11-05 18:45:48
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: Display 5 most recent articles with same custom field value
Hi again,
I suspect you misunderstood how the plugins works.
Let’s go step by step:
1) you have to set your cf names as you would do normally (with no spaces and lowercase) in the glz tab under extensions.
2) you have to configure my plugin as reported in the instructions
3) now you’ll see the “cf title” in the “write” tab, but it will continue to be stored in the db with the original name with no spaces you set before
4) you can use article_custom but with the original name
I hope it’s more clear now.
Last edited by redbot (2010-11-06 01:46:07)
Offline