Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Using custom field in article_custom
This is driving me batty.
I have a series of articles with a custom field named “photographer” and I want to view all articles with the photographer named “Bob Loblaw”
<txp:article_custom photographer=‘Bob Loblaw’ /> does exactly what I want.
However, if I want to use Custom Field with it:
<txp:article_custom photographer=’<txp:custom_field name=“photographer” />’ />
it doesn’t work – even though I can print the name <p><txp:custom_field name=“photographer” /></p> correctly in the form.
asy_wondertag has always been my friend in these circumstances, but even it has abandoned me.
Offline
Re: Using custom field in article_custom
amordecosmos wrote:
<txp:article_custom photographer=’<txp:custom_field name=“photographer” />’ />
Where’s your article_custom tag? Is it in an article body or an article form? If not — and it’s directly on your Page template or somehow in ‘list’ mode — you won’t be able to read the custom field name out of an article because there’s no article to get the field from! (if that makes any sense at all…)
Essentially, in a list, <txp:custom_field name="photographer" />
returns ""
(i.e. nothing).
If it’s not that I’m a bit stumped. Ordinarily I’d say it’s the HTML encoding getting in the way, but with no ‘weird’ characters in Bob’s name it won’t be that.
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: Using custom field in article_custom
The article_custom tag is in the form.
To clarify:
I have an article with custom field ‘photographer’ filled with ‘Bob Loblaw’
The article tag is on the page.
The article tag calls my form:
<txp:if_individual_article>
<txp:title />
<txp:body />
<txp:custom_field name='photographer' /> <!-- So I can see verify that the custom field is indeed being pulled -->
<txp:article_custom form='showTitleOfArticleOnly' photographer='<txp:custom_field name="photographer" />' />
</txp:if_individual_article>
Offline
Re: Using custom field in article_custom
amordecosmos wrote:
The article_custom tag is in the form.
OK, thought as much. Didn’t mean to be patronising. I was going to post this as an EDIT but figured I’d wait until you replied.
This works for me in my article form:
<txp:article_custom photographer='<txp:custom_field name="photographer" />'>
<txp:title />
</txp:article_custom>
so I don’t know what’s going on in your installation, short of the form you’re using being mangled (which I doubt). It certainly should work. Guess it’s a case of eliminating things and finding which part’s misbehaving (does debugging mode show anything untoward, or give any clues?)
You’re using TXP 4.2.0, right? (or 4.0.7+ at least)
Last edited by Bloke (2010-02-11 17:12:27)
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
#5 2010-02-11 19:25:09
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using custom field in article_custom
amordecosmos wrote:
<txp:custom_field name='photographer' />
Quotes? <txp:custom_field name="photographer" />
, <txp:article_custom form="showTitleOfArticleOnly" />
Last edited by els (2010-02-11 19:26:35)
Offline
Re: Using custom field in article_custom
Thank you Bloke & Els.
It’s still not working – I’m aiming for creating author bios without using a plug-in – but it may be my mixing too many article tags on one page. I’ll have to rethink this.
Offline
#7 2010-02-11 22:13:34
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using custom field in article_custom
amordecosmos wrote:
but it may be my mixing too many article tags on one page. I’ll have to rethink this.
No, it should work fine. You can check the tag trace for pointers, or post it here if you can’t find anything.
Offline
Re: Using custom field in article_custom
I need help doing something very similar to this.
On my film review site each individual review article has film information displayed in the left sidebar. Director, country, year, etc. All of this info is pulled from custom fields. What I want is to be able to click on a director’s name in the sidebar which then displays a list of other film reviews for which he is director.
Obviously the section is “Reviews,” the page template is also called “reviews,” the two relevant forms being called by the page are “review” (article form) and “sidebar_review” (misc form).
Any simple way of doing this without plugins?
Edit: Sorry I can’t help, amordecosmos. We’re in the same spot. :) And yes, this too is driving me batty.
Last edited by th3lonius (2010-02-11 22:53:42)
Offline
#9 2010-02-11 23:08:27
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using custom field in article_custom
th3lonius wrote:
What I want is to be able to click on a director’s name in the sidebar which then displays a list of other film reviews for which he is director.
Should that list appear on the same page when the director’s name is clicked, or on a separate page?
Offline
Re: Using custom field in article_custom
A different page. Or the same page with a different form? I don’t know, a different page I suppose. :)
As an extension of this problem, I was also wondering if there’s a way to make custom fields searchable? So if someone uses my search field to find “Ingmar Bergman” the results would be a list of film reviews, the same effect as using the sidebar link.
Offline
#11 2010-02-12 00:13:00
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Using custom field in article_custom
th3lonius wrote:
A different page. Or the same page with a different form? I don’t know, a different page I suppose. :)
On a different page: link to the director’s page like this for example:
<a href="/reviews/?director=<txp:custom_field name="director" />"><txp:custom_field name="director" /></a>
and use adi_gps to display the right content.
You can display it on the same page without needing a plugin. Put the article list in a div that you can hide and show with jQuery. Article list like this:
<txp:article_custom director='<txp:custom_field name="director" />'>
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
As an extension of this problem, I was also wondering if there’s a way to make custom fields searchable? So if someone uses my search field to find “Ingmar Bergman” the results would be a list of film reviews, the same effect as using the sidebar link.
Yet another plugin: wet_haystack
Offline
Re: Using custom field in article_custom
amordecosmos, I think it would be helpful to know what your actual desired html output will be. Are you sure you need to be calling an article_custom
tag within an article
form?
Offline
Pages: 1