Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2012-08-10 16:40:38
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Article Custom and Custom Field And/Or Statement
I have the need to use article_custom, but limit it to what is returned by two possible values that may be in a custom field. The custom field is a drop down using Gerhard’s Custom Fields has numerous names in it, but I only want articles written by Bill Smith or Dave Twain.
I have tried multiple variations of the following with no success, but have a feeling the answer is right under my nose.
<txp:article_custom sort="Posted desc" limit="3" Author="Bill Smith,Dave Twain" />
I cannot use seperate statements because I want the total number returned always to be three —-
Any assistance would be greatly appreciated.
progre55
Last edited by progre55 (2012-08-10 16:44:11)
Offline
#2 2012-08-10 19:13:48
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Re: Article Custom and Custom Field And/Or Statement
So, it’s your custom field that’s named author, right? article_custom has its own attribute named author, so there’ll be a naming conflict.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#3 2012-08-10 19:21:01
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: Article Custom and Custom Field And/Or Statement
uli:
That is what I originally thought — and it may be true — but I tried the above changing Author to Writer and still unable to get it to work.
Offline
#4 2012-08-10 19:45:24
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Re: Article Custom and Custom Field And/Or Statement
Yes, TXP expects the value to be exactly the content of the custom_field. So you’ve got to go the detour of putting two article_custom tags (one for each author), outputting article_id
s, inside the id
attribute of your article_custom tag. In theory ;)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#5 2012-08-10 19:51:46
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: Article Custom and Custom Field And/Or Statement
outputting article_ids, inside the id attribute of your article_custom tag
Not sure I know exactly what you mean —-
If my form reads like this
<txp:article_custom sort="Posted desc" limit="3" Writer="Bill Smith" />
<txp:article_custom sort="Posted desc" limit="3" Writer="Dave Twain" />
Not sure how I can get the articles to be a comination of the both to total 3 — have the three be the most recent — and have the most recent ones —- regardless of writer on top —-
Offline
#6 2012-08-10 19:59:16
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Re: Article Custom and Custom Field And/Or Statement
In theory, not tested:
<txp:article_custom sort="Posted desc" limit="3" id='<txp:article_custom break="," Writer="Bill Smith"><txp:article_id /></txp:article_custom>,<txp:article_custom break="," Writer="Dave Twain"><txp:article_id /></txp:article_custom>' />
No need to limit or sort the inner article tags, the outer tag does all that.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#7 2012-08-10 20:04:12
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Re: Article Custom and Custom Field And/Or Statement
Not sure I mentioned that you’ve got to change the contents of your form ;)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Article Custom and Custom Field And/Or Statement
This is not a perfect solution ( used direct call custom_3
), but …
<txp:aks_article sort="Posted desc" limit="3" where="custom_3 in ('Bill Smith', 'Dave Twain') " />
aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)
Offline
#9 2012-08-14 15:27:47
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: Article Custom and Custom Field And/Or Statement
makss:
Will definitely take a look at this ..
Thanks for the direction.
progre55
Offline
Re: Article Custom and Custom Field And/Or Statement
Here is another (untested) solution:)
<txp:variable name="writer1" value='<txp:article_custom break="," Writer="Bill Smith"><txp:article_id /></txp:article_custom>' />
<txp:variable name="writer2" value='<txp:article_custom break="," Writer="Dave Twain"><txp:article_id /></txp:article_custom>' />
<txp:article_custom limit="3" id='<txp:variable name="writer1" />,<txp:variable name="writer2" />' sort="posted desc">
...your containing statements
</txp:article_custom>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline