Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-08-22 18:09:17

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

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

#2 2008-08-22 18:34:38

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

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

#3 2008-08-22 18:39:54

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#4 2008-08-22 19:17:41

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

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_fields. 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_fields 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,319

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

#6 2008-08-22 21:19:09

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#7 2008-08-23 00:30:43

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

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

#8 2008-08-23 00:56:42

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#9 2008-08-23 01:01:29

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

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

#10 2008-08-23 01:07:08

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

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

#11 2008-08-23 01:16:23

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

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

#12 2008-08-23 01:22:09

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

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

#13 2008-08-23 03:30:44

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: if_custom_field returning false unexplainably

Hi John, it’s getting funny to find out what’s going on :D

I’m almost sure there is something conceptually wrong on the idea of using txp:article/txp:article_custom on a form already called by another txp:article.
Inside an article form (a form called by txp:article/txp:article_custom you usually put article tags ( txp:title, txp:body, etc) and not others txp:article/txp:article_custom tag.
But then, I’m a little confused about what you are trying to achieve.

0. Please, could you explain colloquially this code (and why it’s called by another txp:article form):

<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>

1. Where are you testing your code? on an individual article context (= at an article URL) or in an article list context (a /section/, for example)?

For example, <txp:category1 /> only makes sense when looking at an individual article. You may want to use <txp:category /> if you want to make it sensible to the current category.

2. Could you please try putting this directly on your default page (to avoid calling them using another txp:article tag?

<txp:article form="_article-info" section="articles" />
<txp:asy_wondertag><txp:article_custom section="publications" category="<txp:category1 />" limit="1" form="_publication-info" /></txp:asy_wondertag>

and also this (also on your default page template):

<txp:article form="_article-info" section="articles" />
<txp:article_custom section="publications" category="[the-category-you-want]" limit="1" form="_publication-info" />

——

3. Another test: keeping your current code organization, change this:

<txp:if_article_section name="articles"><txp:article form="_article-info" /></txp:if_article_section>

to any of this:

<txp:if_article_section name="articles"><txp:output_form form="_article-info" /></txp:if_article_section>

or

<txp:if_article_section name="articles">... your article tags like txp:title, txp:if_custom_field, etc... </txp:if_article_section>

——

4. Also, could you describe the desired output? (not the HTML but a sentence describing it)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#14 2008-08-23 05:52:58

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 1,000
Website

Re: if_custom_field returning false unexplainably

Also, could you describe the desired output?

This seems like the best place to start. The purpose of this site is to facilitate open commentary on articles in several hundred publications. Each article will have a stub in the index with associated discussions (comments). (Here “article” refers to a specific writing featured in a publication, as distinct from a txp:article; some txp:articles on this site will be articles. Some will be publications, some will be site copy and documentation.)

Each article landing page must include the following:

  1. Article title
  2. Article excerpt
  3. Article rating
  4. Article tags/keywords
  5. Other article-specific information (Volume/Issue, Page numbers, File-URL, etc., when available)
  6. Information about the publication (Title, Publisher, Publisher URL, etc.)
  7. Category keywords for the publication
  8. Comments

I’m using txp:title, txp:body, and txp:posted for the title, excerpt, and publication date respectively.

I’m using custom fields to capture the other article metadata, such as volume/issue numbers, page numbers, and file URLs, when available. I’m using txp:category1 to group articles by publication.

Based on Zanza’s advice, I’ve set up a separate section for publications, in which each publication has an article with the associate metadata, also using custom fields. Zanza recommended using chh_related_articles to get the publication info, but I couldn’t get it to express the publication data from my _publication-info form. I’d be happy to use a related_articles method instead if I could get it to render the actual publication info and not just a link.

(Since this involves a lot of custom fields, and several of them reuse the same options multiple times, I use glz_custom_fields and sed_section_fields to collect the right information in the right sections.)

Does that make sense?

Please, could you explain colloquially this code (and why it’s called by another txp:article form)?

I think this answer will be more sensible now.

The _article-info form is a snippet that loads article-specific metadata: volume/issue, pages, URL-info, etc.

The _publication-info form is a snippet that loads publication-specific metadata: title, publisher, URL, categories (using tru_tags), etc.

I could put the contents of the _article-info form directly in the default article form, but Textpattern renders it perfectly either way.

Calling _publication-info from within the “articles” section is a bit trickier— I tried chh_related_articles, and I couldn’t get it to work. Using txp:article_custom within the wondertag to get the publication-section article that matches by category1 works: It renders the title, links to the publication information page, and renders the keywords. The only things that won’t render are the txp:if_custom_field and txp:custom_field requests.

Where are you testing your code? on an individual article context (= at an article URL) or in an article list context (a /section/, for example)?

This is probably already clear— the context is from an article URL, within the if_individual_article condition.

Tests

2. Could you please try putting this directly on your default page (to avoid calling them using another txp:article tag?

The output is identical to using them within the default.article form, accept without comments: contents of _article-info render perfectly, including custom fields; contents of publication_info render partially, excluding custom fields.

2b. and also this (also on your default page template):

Same as before, as long as I view the same article (other articles are associated with different publications through category1).

3. Another test: keeping your current code organization—

<txp:if_article_section name="articles"><txp:output_form form="_article-info" /></txp:if_article_section>

Wow. output_form works the same as txp:article; I get the full rendering of the form without disrupting space-time. Nice.

<txp:if_article_section name="articles">... your article tags like txp:title, txp:if_custom_field, etc... </txp:if_article_section>

Yes, this works too. Indeed, that’s how I started, but the form got a bit unwieldy and I moved this piece out to its own form.

Of these options, I prefer the output_form suggestion. Thanks!

Unfortunately, the custom fields in _publication-info return false in all these tests, even while it continues to render the correct title, permlink, and keywords.

Offline

#15 2008-08-23 16:44:51

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: if_custom_field returning false unexplainably

(Since this involves a lot of custom fields, and several of them reuse the same options multiple times, I use glz_custom_fields and sed_section_fields to collect the right information in the right sections.)

Are the custom fields on _publication-info on the “range” (10+) of glz_custom_fields “managed” custom fields?
Could you test using a custom field between the first ten custom fields? Also, could you do that test both with glz_custom_fields enabled and disabled?

(In other words, try to test if glz_custom_fields may be related to the issue)

Thanks!


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB