Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: archive examples...
Okay, similar trick but new twist; a single column layout and using conditionals.
The homepage is broken up into different content sections representing the main sections of the website. Something like this….
<div role="main">
<section>
<h1>About</h1>
...content...
</section>
<section>
<h1>Work</h1>
...content...
</section>
<div role="complementary">
<h1 class="section allcaps">Articles</h1>
<txp:article form="default" limit="1" />
<div id="archcats">
<txp:output_form form="article-categories" />
</div>
</div>
<footer>
<h1>Contact</h1>
...content...
</footer>
</div>
The “Articles” section of the homepage contains the title and excerpt of the latest article, followed by a list of article categories. When you click a category, you’re taken to the Archive section of the website where the articles associated with that category are listed, followed by the category list again so that a person can choose another topic category if they want. This works as expected, represented by the move from Homepage to /archive/category in the following diagram; a person can click a category link on the homepage and the correct articles are displayed…
It’s possible someone might arrive at the Archive landing page without first clicking through the categories (e.g, directly from Google), so there needs to be a default output for the Archive landing page context, and that’s why I’m trying to do this with a conditional. For that part of the conditional, I just need to output the sticky article (body) and the category list, as the red page above suggests.
Here is the current Archive page code that behaves like the diagram describes (I know, I’m probably over doing it here)…
<txp:if_article_list>
<p>Oh, <span class="capitalize important"><txp:category /></span>. Nice! Here's what I have for you...</p>
<txp:article_custom category='<txp:category />' form="archive-topic-list" sort="posted desc" wraptag="ul" break="li" section="articles" />
<p>Try another?</p>
<div id="archcats">
<txp:output_form form="categories-list" />
</div>
<txp:else />
<p>All articles are organized by the following categories. Pick and go!</p>
<div id="archcats">
<txp:output_form form="categories-list" />
</div>
</txp:if_article_list>
But I can’t get this part to work. Instead of just the sticky and category list, I get the two paragraphs from the first part of the conditional (p1 and p2) with all articles listed in between. I’m sure it’s partly to do with the conditionals, which I’m always confused about when mixing articles and categories, but it’s likely something else.
I’ve also tried other conditional combinations, like if_category
and if_article_section
(that tag I don’t understand at all), but those never quite work either.
Any ideas?
Ed.: Remembering to try a tag trace.
Last edited by Destry (2012-12-03 22:54:51)
Offline
#14 2012-12-03 22:45:19
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: archive examples...
Destry wrote:
Where is that code wrong? I’m sure it is.
I think it’s category='<txp:category />'
. On a page that is not a category page the output is category=""
, and that, as far as I know, means ‘any category’.
So, you do need if_category.
<txp:if_article_list>
<txp:if_category>
<!-- category page -->
<p>Oh, <span class="capitalize important"><txp:category /></span>. Nice! Here's what I have for you...</p>
<txp:article_custom category='<txp:category />' form="archive-topic-list" sort="posted desc" wraptag="ul" break="li" section="articles" />
<p>Try another?</p>
<txp:else />
<!-- archive landing page -->
<p>All articles are organized by the following categories. Pick and go!</p>
</txp:if_category>
<!-- this appears on both landing and category page -->
<div id="archcats">
<txp:output_form form="categories-list" />
</div>
<txp:else />
<!-- individual article page -->
</txp:if_article_list>
Offline
Re: archive examples...
And just like that you make it look so easy.
I just can’t seem to get my head around the different conditional contexts. I always struggle with it.
Thank you, Els. I spent all day racking my brain on that.
Offline