Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
if_custom_field returning false unexplainably
Hi!
I have a form that isn’t displaying certain fields of data; here’s the debugging tag trace:
<txp:title/>
<txp:if_custom_field name="publisher">
[<txp:if_custom_field name="publisher">: false]
</txp:if_custom_field>
<txp:if_custom_field name="publisher-url">
[<txp:if_custom_field name="publisher-url">: false]
</txp:if_custom_field>
<txp:if_custom_field name="category">
[<txp:if_custom_field name="category">: false]
</txp:if_custom_field>
<txp:chh_if_data>
[<txp:chh_if_data>: true]
<txp:keywords/>
<txp:hide>
</txp:hide>
</txp:chh_if_data>
Textpattern correctly parses the title and keywords but not the custom fields. I have verified that, for this article, there is data in each of the fields that returns “false” and I’m not sure what’s the problem is.
Any ideas? Thanks in advance!
Offline
Re: if_custom_field returning false unexplainably
I’m not sure I understand what you’re trying to accomplish here, but one thing that can be your problem is the use of <txp:if_custom_field>
inside another <txp:if_custom_field>
. You should use <txp:custom_field name="field" />
Last edited by variaas (2008-08-22 19:09:33)
Offline
Re: if_custom_field returning false unexplainably
@variasas,
I though the same at first, but johnstephens isn’t using nested if_custom_field. It’s just the output of the tag trace, that looks like nested if_custom_field.
I can’t see anything wrong. There are some issues if custom fields names collapse with some article fields (like “title”, “keywords”, “excerpt”, etc), but it doesn’t seem to be this case.
Offline
Re: if_custom_field returning false unexplainably
Your right, maniqui. I’ve double checked and I don’t have any if_custom_field
nesting.
I have a nearly identical form in another section that uses the same method and worked perfectly. I can’t understand why this form is showing the title and keywords (and the permlink, which I forgot to mention) but is saying “false” on the if_custom_field
s. I’m somewhat baffled by it.
I just tested it without the conditional tags, and it’s behavior is still not what I would expect (form code):
<h3>About <txp:permlink><txp:title /></txp:permlink></h3>
<txp:custom_field name="publisher" /><br />
<a href="<txp:custom_field name="publisher-url" />" title="<txp:custom_field name="publisher-url" />" rel="nofollow">Homepage</a><br />
<txp:custom_field name="category" />
The tag-trace doesn’t show any problems:
<txp:permlink>
<txp:title/>
</txp:permlink>
<txp:custom_field name="publisher" />
<txp:custom_field name="publisher-url" />
<txp:custom_field name="publisher-url" />
<txp:custom_field name="category" />
But the HTML appears thus:
<h3>About <a rel="bookmark" href="http://link/to/publication/record">Publication Title</a></h3>
<br />
<a href="" title="" rel="nofollow">Homepage</a><br />
Maybe it’s context?
I’m using this line to grab the form:
<txp:asy_wondertag><txp:article_custom section="publications" category="<txp:category1 />" limit="1" form="_publication-info" /></txp:asy_wondertag>
Directly before that, I have the similar form that outputs the if_custom_field
s correctly:
<txp:if_article_section name="articles"><txp:article form="_article-info" /></txp:if_article_section>
Please let me know if more detail is needed. Thanks again for your guidance and support!
Offline
#5 2008-08-22 21:11:02
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: if_custom_field returning false unexplainably
John, the case where the custom fields output their content, is it grabbed from the cf with the same name? With the hyphen you have an … errm … well … “forbidden” character in your custom field’s name. I had spaces, dots and apostrophes in mine, and it worked. But it’s not officially supported.
TextBook wrote:
Custom names may include letters (uppercase or lowercase), numbers and under_scores, but no spaces or other special characters.
Last edited by uli (2008-08-22 21:12:01)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: if_custom_field returning false unexplainably
uli is right, probably that’s the problem: the hyphens. I’ve had it few weeks ago.
BTW, this code:
<txp:if_article_section name="articles"><txp:article form="_article-info" /></txp:if_article_section>
doesnt’ make too much sense.
txp:if_article_section
is meant to be used inside an article form.
You are probably trying to do this:
<txp:if_section name="articles"><txp:article form="_article-info" /></txp:if_section>
(sorry if I’m wrong)
Offline
Re: if_custom_field returning false unexplainably
@uli Thanks, I’ll try removing the hyphens and see if it works— but I note there are hyphens in the form that is working
@maniqui Both <txp:if_article_section...
and the <txp:asy_wondertag><txp:article_custom...
appear in the context of an article form. The former is working fine.
Offline
Re: if_custom_field returning false unexplainably
Hi John,
So, are you callling a form that contains <txp:if_section name="articles"><*txp:article* form="_article-info" /></txp:if_section>
from another *txp:article*
?
I may be totally wrong, but you can’t use a txp:article tag inside an article form, which is called by another txp:article.
That may break the space-time continuum, or your custom fields.
But correct me if I’m wrong.
Offline
Re: if_custom_field returning false unexplainably
uli wrote
John, the case where the custom fields output their content, is it grabbed from the cf with the same name?
Yes, that’s the intention: If it has data in this field, show the data in the field along with a label.
With the hyphen you have an … errm … well … “forbidden” character in your custom field’s name. I had spaces, dots and apostrophes in mine, and it worked. But it’s not officially supported.
maniqui wrote
uli is right, probably that’s the problem: the hyphens. I’ve had it few weeks ago.
I replaced the hyphens with underscores in both the custom fields and in my form, but the outcome is no different. Even if the hyphen was the problem, only one of the custome fields contained a hyphen in this form, and none of them evaluate as “true,” with or without the hyphen. Also, the other form contains many custom fields with hyphens, and all of them are parsed correctly:
<txp:if_article_section name="articles"><txp:article form="_article-info" /></txp:if_article_section>
This the the tag-trace for the preceding form, in which Textpattern correctly recognises that each conditional comment is : true]
:
<txp:body/>
<txp:if_excerpt>
[<txp:if_excerpt>: false]
</txp:if_excerpt>
<txp:if_custom_field name="article_doctype">
[<txp:if_custom_field name="article_doctype">: true]
<txp:custom_field name="article_doctype" />
</txp:if_custom_field>
<txp:chh_if_data>
[<txp:chh_if_data>: true]
<txp:keywords/>
<txp:hide>
</txp:hide>
</txp:chh_if_data>
<txp:if_custom_field name="article_file-url">
[<txp:if_custom_field name="article_file-url">: true]
<txp:custom_field name="article_file-url" />
<txp:custom_field name="article_file-url" />
</txp:if_custom_field>
<txp:if_custom_field name="article_file-format">
[<txp:if_custom_field name="article_file-format">: true]
<txp:custom_field name="article_file-format" />
</txp:if_custom_field>
<txp:if_custom_field name="article_access">
[<txp:if_custom_field name="article_access">: true]
<txp:custom_field name="article_access" />
</txp:if_custom_field>
<txp:if_custom_field name="article_pages">
[<txp:if_custom_field name="article_pages">: true]
<txp:custom_field name="article_pages" />
</txp:if_custom_field>
<txp:if_custom_field name="article_volume-issue">
[<txp:if_custom_field name="article_volume-issue">: true]
<txp:custom_field name="article_volume-issue" />
</txp:if_custom_field>
<txp:posted/>
I see in my eMail that someone else is posting, so I’ll hurry up and click submit.
Last edited by johnstephens (2008-08-23 01:27:31)
Offline
Re: if_custom_field returning false unexplainably
maniqui wrote:
So, are you callling a form that contains
<txp:if_section name="articles"><*txp:article* form="_article-info" /></txp:if_section>
from another*txp:article*
?
Yes.
That may break the space-time continuum, or your custom fields.
Well, I took out that line, and it still doesn’t parse the custom fields in the other form. As you can see from the tag-trace in the previous message, that form is actually outputting everything the way I want. The article tag that is exibiting space-time anomolies is:
<txp:asy_wondertag><txp:article_custom section="publications" category="<txp:category1 />" limit="1" form="_publication-info" /></txp:asy_wondertag>
Offline
Re: if_custom_field returning false unexplainably
maniqui wrote:
So, are you callling a form that contains
<txp:if_section name="articles"><*txp:article* form="_article-info" /></txp:if_section>
from another*txp:article*
?
I said yes, but I didn’t read your question carefully. Here’s my setup:
Page: default.txp (excerpt):
<txp:article />
Article Form: default.article.txp (exceprt):
<txp:if_article_section name="articles"><txp:article form="_article-info" /></txp:if_article_section>
<txp:asy_wondertag><txp:article_custom section="publications" category="<txp:category1 />" limit="1" form="_publication-info" /></txp:asy_wondertag>
Article Form: _article-info is parsed, as previously noted, exactly like I want.
Article Form: _publication-info is parsed partially, ignoring any data contained between the conditional tags (which the tag race incorrectly evaluates as : false]
.
If this is a breech of time-space protocols, why does it work in the first instance and not the second?
Thanks so much for your help!
Offline
Re: if_custom_field returning false unexplainably
Just to see if the anomaly is caused by using txp:article
and txp:article_custom
from within an article form, I replaced my article form on the default page with these.
The behavior was identical to using them within the article form: the _article-info
form’s custom fields show up, and the _publication-info
form’s custom fields don’t.
Help!
Offline