Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
asign form with custom field in article list
Hi,
I need to display articles in a list using one of two forms depending on a custom field.
Is this possible? Here is what I’ve tried so far with no success.
<txp:article_custom category="somecategory" form="<txp:custom_field name='custom1' />" />
<txp:article_custom category="somecategory" form="<txp:custom_field name="custom1" />" />
thanks
Last edited by kvnmcwebn (2010-05-27 12:52:01)
its a bad hen that wont scratch itself.
photogallery
Offline
Re: asign form with custom field in article list
Single quotes go around the entire attribute that you want TXP to parse, like this:
<txp:article_custom category="somecategory" form='<txp:custom_field name="custom1" />' />
Effectively, the single quotes ‘enclose’ the tag-in-your-attribute. It gets hairier if you want to embed another tag inside that tag, but for now that’ll get you going.
P.S. don’t forget to check that the custom field has something in it first, or your tag’ll use the default form!
Last edited by Bloke (2010-05-27 12:55:29)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: asign form with custom field in article list
doh.. I was trying the single quotes inside the double…
thanks a million bloke.
its a bad hen that wont scratch itself.
photogallery
Offline
Re: asign form with custom field in article list
hmm
<txp:article_custom category="auctioneers" form='<txp:custom_field name="custom1" />' sort="Title desc" />
Am I using the wrong sort of quotes above?
It doesn’t output an article list at all like that.
like this it outputs the articles with an emty form (“”)
bc. <txp:article_custom category=“auctioneers” form=’<txp:custom_field name=“custom1” />’ sort=“Title desc” />
Last edited by kvnmcwebn (2010-05-27 13:24:29)
its a bad hen that wont scratch itself.
photogallery
Offline
Re: asign form with custom field in article list
Did you name your custom field “custom1” in the preferences? In txp:custom_field the name attribute takes the display name for your custom field: name="displayname-for-custom-field"
.
TXP Builders – finely-crafted code, design and txp
Offline
Re: asign form with custom field in article list
hi yes I’m just using the original custom1 field. It’s already named in the prefs.
its a bad hen that wont scratch itself.
photogallery
Offline
Re: asign form with custom field in article list
it might be something with the quotes cos that just doesn’t render anything at all.
its a bad hen that wont scratch itself.
photogallery
Offline
#8 2010-05-27 15:42:14
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: asign form with custom field in article list
Your code needs to be in an individual article context to work, the individual article’s custom field would then be the value of the form
attribute.
If you rather meant to use the custom field of the articles displayed by the article_custom tag, you’d better have a look at the ‘override form’ option in the Write screen.
Offline
Re: asign form with custom field in article list
Hi El’s.
That would be the perfect solution if i could get it working. Is there any reason why the form won’t be overidden in the below code?
<txp:article_custom category="architects" form="page_listing" sort="Title desc" />
its a bad hen that wont scratch itself.
photogallery
Offline
#10 2010-05-27 21:23:40
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: asign form with custom field in article list
I guess you need to add allowoverride="1"
(article_custom attributes).
(edit: fixed typo)
Last edited by els (2010-05-27 21:25:09)
Offline
Re: asign form with custom field in article list
ahh thanks el’s that does the trick. i’ve never used this feature before. sorry for the slowness.
its a bad hen that wont scratch itself.
photogallery
Offline