Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
News listing problem
I’m using TXP for quite some time, but this one puzzles me. I have various news articles all assigned to section “news” and category “news”. All of them have an excerpt text as well. The original news page has a short intro text and also the section “news” assigned. On my page template I have the following:
<txp:article form="static_text_news" />
<txp:article_custom section="news" category="news" limit=3 form="news_excerpt"
Article form “static_text_news”:
<h2><txp:title /></h2>
<txp:body />
Article form news_excerpt:
<h3><a href="<txp:permlink />"><txp:title /></a></h3>
<p class="p_italic_news"><txp:posted /></p>
<p id="newsText"><txp:excerpt /><a href="<txp:permlink />"> Read more...</a></p>
When loading the news page I get the static text of the original news page (intro text) and the three listings as they should be. The problem is when I click on one of the links in the lists i.e. heading or read more. The main into text at the top gets replaced with the content of the selected/clicked news text and the same three items stay below (including the same which was clicked).
Surely there is a simple answer to what I’m doing wrong.
Many thanks in advance
otti
Offline
Re: News listing problem
otti wrote:
When loading the news page I get the static text of the original news page (intro text) and the three listings as they should be. The problem is when I click on one of the links in the lists i.e. heading or read more. The main into text at the top gets replaced with the content of the selected/clicked news text and the same three items stay below (including the same which was clicked).
Surely there is a simple answer to what I’m doing wrong.
Hi Otti, what should it do instead?
The article tag is context sesitive, where’s article_custom isn’t.
This means that the <txp:article />
will always display the content which is relevant to the context. For example if you are viewing an individual article, the tag will always show an individual article.
If you don’t want the article tag to show the individual article, you can use article custom instead. For example:
<txp:article_custom form="static_text_news" section='<txp:section />' />
If you want a different view for lists and individual articles, you can use conditionals, for example:
Let’s say that you want to replace the category item list with the main article:
<txp:if_individual_article>
<txp:article />
<txp:else />
<txp:article_custom section="news" category="news" limit="3" form="news_excerpt" />
</txp:if_individual_article>
And some additional notices about your code:
<txp:article_custom section="news" category="news" limit=3 form="news_excerpt"
- Always close tags.
- Surround numbers with quotes.
Additional notes about things used in the examples above:
Last edited by Gocom (2010-08-14 13:17:29)
Offline
Re: News listing problem
Hi Gocom,
First of all a big thank you for making the effort and answering on my post so extensively. I appreciate your advice about closing tags (I actually do, just did not copy the slash and closi9ng bracket when posting, sorry). I also see the point of surrounding numbers with quotes.
My problem is still not solved and I think I could do with a bit more of advice. All I really want is writing news articles and have them displayed on my news page as excerpt. When a user clicks on the heading or the read more link, the news page changes and displays this particular article in full. So, where is my problem? As you have mentioned about the <txp:article />
tag I thought I require it to display the generic text, written in the first news article. Also it’s there to show the individual article, when clicked, correct?
I tried your code example with <txp:if_individual_article>
but this results in showing only the first news article.
I also tried the article_list as suggested by you. I thought with having articles associated with the same section and category I have a “list” already but apparently not, correct? So I tried to use the prefabricated “article_listing” form but that also doesn’t get me anywhere.
Could you possibly give me an example how you would do a news page, showing a list of excerpts of a limited amount of articles? I don’t know where my thought process goes wrong here, but I need to fix this.
Many thanks
otti
Offline
Pages: 1