Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2015-01-01 01:26:07
- Derekstaff
- Member
- Registered: 2014-10-23
- Posts: 28
Form not calling any articles
I’m trying to code my home page so that it displays separately excerpts from the latest two articles from two particular sections. I’ve created a form for this:
<txp:if_first_article><ul id="article-list"></txp:if_first_article>
<li role="article" itemscope itemtype="http://schema.org/Article">
<h1 class="med-heading" itemprop="name"><a href="<txp:permlink />" itemprop="url"><txp:title /></a></h1>
<!-- if the article has an excerpt, display that -->
<txp:if_excerpt>
<div itemprop="description">
<txp:excerpt />
</div>
</txp:if_excerpt>
<p class="footnote"><txp:text item="posted" /> <time datetime="<txp:posted format='iso8601' />" itemprop="datePublished"><txp:posted /></time>, <txp:text item="author" /> <span itemprop="author"><txp:author link="1" this_section="1" /></span></p>
<p class="footnote"><txp:keywords /></p>
</li>
<txp:if_last_article></ul></txp:if_last_article>
I then use the form twice, each time directing it to call different sections.
<h1 class="minor-heading page-title">Recent Posts</h1>
<section class="recent-posts" id="upcoming-events">
<h1 class="major-heading">Upcoming Events</h1>
<div class="tease-group">
<txp:article_custom form="tease_listing" section="4calendar" excerpted="y" limit="2" />
</div>
<p><a href="./?s=4calendar" class="blog_link">See the entire Calendar</a></p>
</section>
<section class="recent-posts">
<h1 class="major-heading">Our Stories</h1>
<div class="tease-group">
<txp:article_custom form="tease_listing" section="6our_stories" excerpted="y" limit="2" />
</div>
<p><a href="./?s=6our_stories" class="blog_link">All our stories.</a></p>
</section>
Both sections are populated with articles.
The second instance of the form works fine, calling up the two most recent articles as intended. The first instance of the form, however, calls up nothing, leaving me with an empty “Upcoming Events” section, as shown here.
The section page itself, when clicked, does show the articles (currently only one article, as my client has not provided me with further articles). I’m still working on the layout, but the content is available.
Any ideas as to why the form is not working properly in the one instance? Seems particularly strange, since it works in the other instance on the same page.
Offline
Re: Form not calling any articles
Switch the website to debug mode via the preferences and look at the debug code in the HTML source to see what happens.
Offline
#3 2015-01-01 16:39:00
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Re: Form not calling any articles
Derekstaff wrote #286982:
“Upcoming Events”
These articles, viewed in Admin > Articles have which color in the “Posted” column, grey?
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#4 2015-01-01 19:27:43
- Derekstaff
- Member
- Registered: 2014-10-23
- Posts: 28
Re: Form not calling any articles
ruud wrote #286990:
Switch the website to debug mode via the preferences and look at the debug code in the HTML source to see what happens.
Thanks for any and all help, guys. I’m very new at Textpattern—or any CMS, actually; everything I’ve done before has all been direct coded html and css—so forgive me if I seem a bit dense.
Ruud, I assume you mean for me to go to the admin>preferences panel, and switch the production status to “debugging?”
Offline
#5 2015-01-01 19:30:06
- Derekstaff
- Member
- Registered: 2014-10-23
- Posts: 28
Re: Form not calling any articles
uli wrote #286998:
These articles, viewed in Admin > Articles have which color in the “Posted” column, grey?
I’m slightly confused. I don’t see any Admin > Articles panel. I checked the Content > Articles panel, and everything in the “Posted” column—articles from both sections—is black text, white background. Is this where you meant me to look?
Offline
Re: Form not calling any articles
Derekstaff wrote #287001:
Ruud, I assume you mean for me to go to the admin>preferences panel, and switch the production status to “debugging?”
Yes. Once you’ve done that. Reload your website and view the HTML source. There’s a lot of debug code at the bottom.
Offline
Offline
#8 2015-01-01 22:21:30
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Re: Form not calling any articles
Derekstaff wrote #287002:
Is this where you meant me to look?
Yes, exactly. That would’ve been a quick answer ;)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#9 2015-01-02 04:21:33
- Derekstaff
- Member
- Registered: 2014-10-23
- Posts: 28
Re: Form not calling any articles
uli wrote #287007:
Yes, exactly. That would’ve been a quick answer ;)
I take it that the fact that it is all in black text doesn’t provide any meaningful clues?
Offline
#10 2015-01-02 04:28:35
- Derekstaff
- Member
- Registered: 2014-10-23
- Posts: 28
Re: Form not calling any articles
ruud wrote #287004:
Yes. Once you’ve done that. Reload your website and view the HTML source. There’s a lot of debug code at the bottom.
Okay, I did as you suggested. As I looked through the debug code at the bottom, I found this that relates to the forms in question
<txp:article_custom form="tease_listing" section="4calendar" excerpted="y" limit="2" />
[SQL (0.00066018104553223): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('4calendar') and Excerpt !='' order by Posted desc limit 0, 2]
<txp:article_custom form="tease_listing" section="6our_stories" excerpted="y" limit="2" />
[SQL (0.00087809562683105): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = '0000-00-00 00:00:00') and Section IN ('6our_stories') and Excerpt !='' order by Posted desc limit 0, 2]
But I don’t see anything in there explaining what’s going wrong. Can you?
Offline
Re: Form not calling any articles
Could it simply be that your article ID#22 (“Mangelson Baptism Jan 4”) does not have an excerpt? On the section page it doesn’t show. Using excerpted="y"
in your article_custom tag will only list articles that have an excerpt. If you add an excerpt to that article, you may find it works.
BTW: The debug output you quote shows the tag and the corresponding database query it produces. Immediately below that, it should list any articles that match. If none appear, it hasn’t matched any.
BTW II: If you want your upcoming events list to still show articles even if no excerpt has been written, try using article_custom without the excerpted attribute and then use txp:if_excerpt to determine if there is an excerpt. For the not case use smd_wrap (see Example 7) or rvm_substr to output a shortened part of the body tag something like this:
<txp:if_excerpt>
<txp:excerpt />
<txp:else />
<txp:smd_wrap_all wraptag="p" transform="strip_tags, cut|180|25w|…">
<txp:body />
</txp:smd_wrap_all>
</txp:if_excerpt>
That will output the body tag chopped to 180 chars, then to 25 words, and then end with an …
if no excerpt has been specified.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Form not calling any articles
The difference in SQL queries is caused by excerpted="y"
which affects <txp:article_custom>
, but not <txp:article>
. This is by design, although there should’ve been a warning about an invalid attribute when you use it for <txp:article>
.
I’ve created an issue for this.
Offline