Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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)
Offline
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:
- Article title
- Article excerpt
- Article rating
- Article tags/keywords
- Other article-specific information (Volume/Issue, Page numbers, File-URL, etc., when available)
- Information about the publication (Title, Publisher, Publisher URL, etc.)
- Category keywords for the publication
- 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
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!
Offline
Re: if_custom_field returning false unexplainably
All of the custom fields that aren’t working are managed by glz_custom_fields
: they are custom_11, 12, and 13. I realized this last night, and I was planning to eMail Gerhard today. I’ll test this out as you suggested first.
Thanks again!
Offline
Re: if_custom_field returning false unexplainably
Indeed, the problem is that the fields are greater than TXP’s original ten, and this function requires a hack.
I’ll try this out, and see what happens.
Offline
Re: if_custom_field returning false unexplainably
Hi John,
any news on this?
I’ve been looking at glz_custom_fields thread and I see there is a txp:glz_article_custom
tag.
You may try using it instead of the built-in tag.
Offline
Re: if_custom_field returning false unexplainably
Hi, Maniqui!
Thanks for your continuing attention and support!
Using the patch and fixing a few problems with my code has totally resolved this issue. At first, I got a new error, but one eMail from Gerhard was all it took to solve the problem.
I have a new challenge that I intend to post separately. Thanks again!
Offline