Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
List of articles troubleshooting
I’m new to Textpattern, and would like an “articles” section to display excerpts rather than full articles. What I have now shows full articles:
<txp:if_category>
<h1><txp:category title="1" /></h1>
<div class="hfeed">
<txp:article limit=1 form="static_article" status="sticky" />
</div>
<txp:else />
<txp:if_search>
<h1><txp:text item="search_results" />: <txp:page_url type="q" /></h1>
</txp:if_search>
<div class="hfeed">
<txp:article limit="5" />
</div>
</txp:if_category>
<txp:if_individual_article>
<p><txp:link_to_prev>« <txp:prev_title /></txp:link_to_prev>
<txp:link_to_next><txp:next_title /> »</txp:link_to_next></p>
<txp:else />
<p><txp:older>« <txp:text item="older" /></txp:older>
<txp:newer><txp:text item="newer" /> »</txp:newer></p>
</txp:if_individual_article>
What I want, according to Textbook: (shows as emptiness / nothingness when I try it now)
<txp:if_article_list>
<txp:if_excerpt>
<txp:excerpt />
<p class="read-more>
<a href="<txp:permlink />#body"
title="<txp:title />">» Read more</a>
</p>
<txp:else />
<txp:body />
</txp:if_excerpt>
<txp:else />
<txp:if_excerpt>
<txp:excerpt />
</txp:if_excerpt>
<div id="body">
<txp:body />
</div>
</txp:if_article_list>
I currently have one article in this section with a completed excerpt and published as “live.”
Thanks for any help! Not sure what’s making it look empty when I try the code from Textbook.
Offline
#2 2010-08-16 22:28:51
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: List of articles troubleshooting
Empty page?
Two guesses:
- The second code block is the only thing in between your opening and closing body tags, and in your preferences Production Status is set to Live?
Put it in a form ( form “static_article”), set Production Status to Debug or Test in order to get some more information.
- You put everything in the right place, but you aren’t viewing a category page.
You should a) use a category link to view the article (you’ve assigned a category) or b) remove theif_category
andelse
tags if they aren’t necessary.
Again: just guesses, you didn’t post the complete code.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: List of articles troubleshooting
Sorry, I should be more clear: The part that’s empty is where the article excerpt should appear. The rest of the site (menus, other content) all appear as normal.
Also, it’s not a category page. It’s a section page that I want to present a list of excerpts + “read more” links, that show a full article when activated.
The code I’ve posted is what I have in between my <div id=“bodytext”></div> area of my website; in other words, that’s the main content section.
Offline
#4 2010-08-16 23:17:09
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: List of articles troubleshooting
I ignored the <txp:article limit="5" />
below the if_search
part, so everything I guessed is a lie.
maruchan wrote:
The code I’ve posted is what I have in between my <div id=“bodytext”></div> area of my website; in other words, that’s the main content section.
Third guess: You posted two code blocks. The second one resides in your form “default” in order to be queried by the above article tag?
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: List of articles troubleshooting
Oh, I didn’t notice that I had the form call in there. It shouldn’t be…that’s how I’m displaying single articles for other sections. For this section I’d like a list of excerpts.
Offline
Re: List of articles troubleshooting
OK, removed it. Here’s what I have now.
<txp:if_category>
<txp:else />
<txp:if_search>
<h1><txp:text item="search_results" />: <txp:page_url type="q" /></h1>
</txp:if_search>
<div class="hfeed">
<txp:article limit="5" />
</div>
</txp:if_category>
<txp:if_individual_article>
<p><txp:link_to_prev>« <txp:prev_title /></txp:link_to_prev>
<txp:link_to_next><txp:next_title /> »</txp:link_to_next></p>
<txp:else />
<p><txp:older>« <txp:text item="older" /></txp:older>
<txp:newer><txp:text item="newer" /> »</txp:newer></p>
</txp:if_individual_article>
That’s working: At least it displays a full-length article. If I could just get this thing showing an excerpt rather than the full article, that would be great. Then I could work on showing a list of excerpts. :-)
Edit: I think if_category is unnecessary but am not sure if I should leave it in there just in case somebody requests a category or what.
Last edited by maruchan (2010-08-16 23:26:34)
Offline
#7 2010-08-16 23:40:38
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: List of articles troubleshooting
What works on your page is the <txp:article limit="5" />
tag below the if_search
part. And it’s querying your form default cause you didn’ specify another one. If it’s not displaying excerpts, the second part of the code you posted in post #1 does not seem to be in that form.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: List of articles troubleshooting
Here’s my form default:
<txp:if_individual_article>
<h1 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h1>
<txp:else />
<h3 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h3>
</txp:if_individual_article>
<div class="entry-content">
<txp:body />
</div>
Do I need to make a change to that?
Offline
Re: List of articles troubleshooting
maruchan wrote:
Do I need to make a change to that?
Yes, but if you are already using the default form for other content, you could:
- Create a new form and call it with the form attribute
- Or you can use the article tag as a container.
For example, from:
<txp:article limit="5" />
To:
<txp:article limit="5">
<txp:excerpt />
</txp:article>
- See article
- See excerpt”:http://textpattern.net/wiki/index.php?title=excerpt
- Tag Reference”:http://textpattern.net/wiki/index.php?title=Category:Tag_Reference
Note that article tags always need to go to article context. They can not be used directly on page template.
Last edited by Gocom (2010-08-17 00:03:45)
Offline
Re: List of articles troubleshooting
OK, I am learning a ton. :-) I made a new form and put this in it:
<txp:if_article_list>
<txp:if_excerpt>
<h3 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h3>
<txp:excerpt />
<p class="read-more">
<a href="<txp:permlink />#body"
title="<txp:title />">» Read more</a>
</p>
<txp:else />
<txp:body />
</txp:if_excerpt>
<txp:else />
<p><a href="http://www.marccarson.com/site">Home</a> > <a href="http://www.marccarson.com/site/articles/">Articles</a></p>
<h1 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h1>
<txp:body />
</txp:if_excerpt>
</txp:if_article_list>
Does that look OK? It seems to work OK but I have no idea how it works exactly…at the bottom before if_excerpt is closed, I have <h1…<txp:body /> — when would that ever be used? Is it necessary?
Offline
#11 2010-08-17 00:34:27
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,315
Re: List of articles troubleshooting
All this
<p><a href="http://www.marccarson.com/site">Home</a> > <a href="http://www.marccarson.com/site/articles/">Articles</a></p>
<h1 class="entry-title"><txp:permlink><txp:title /></txp:permlink></h1>
<txp:body />
is displayed on individual articles’ pages. [EDIT: You’re in the “else” part of if_article_list
] BTW You should delete the last if_excerpt
tag, you have two closing ones.
Last edited by uli (2010-08-17 00:44:03)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: List of articles troubleshooting
Is this <txp:body> necessary?
<txp:else />
<txp:body />
</txp:if_excerpt>
I’m not sure why that would be useful.
I deleted the other if_excerpt tag.
Offline