Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-05-09 20:54:31

Riyonuk
New Member
Registered: 2008-05-08
Posts: 9

Archive Page

If I was creating a static website, this would be easy…well not exactly easy, just easier :P

This is how I intended it to look…

<h3 id="late">Archives</h3>
<h4>In Chronological Order</h4>
<p>January</p>
<ul>
	<li><a href="#">Article Title</a></li>
	<li><a href="#">Article Title</a></li>
	<li><a href="#">Article Title</a></li>
	<li><a href="#">Article Title</a></li>
</ul>
<p>February</p>
<ul>
	<li><a href="#">Article Title</a></li>
	<li><a href="#">Article Title</a></li>
	<li><a href="#">Article Title</a></li>
	<li><a href="#">Article Title</a></li>
</ul>

So I created this within a form…

<txp:if_different>
<p><txp:posted format="%B" /></p>
</txp:if_different>
<ul>
<li><txp:posted format="%B" />: <txp:permlink><txp:title /></txp:permlink> (<txp:comments_count />)</li>
</ul>

And it comes out with this, which is not what I want :P – The whole multiple unordered list tags, I just want one, sheesh. Also, am I going about this the right way? For creating an archive page, that is ;)

<h3>May 2008</h3>
<ul><li><a rel="bookmark" href="http://riyonuk.no-ip.org/logbook/blah">blah</a></li></ul>
<ul><li><a rel="bookmark" href="http://riyonuk.no-ip.org/thehunter/fg">fg</a></li></ul>
<ul><li><a rel="bookmark" href="http://riyonuk.no-ip.org/thehunter/test">dfg</a></li></ul>

Offline

#2 2008-05-09 21:24:04

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Archive Page

Always a pain, if_different and lists… :( I know this works, but it’s not pretty:

<txp:if_first_article>
<ul style="display:none;">
</txp:if_first_article>
<txp:if_different>
</ul>
<p><txp:posted format="%B" /></p>
<ul>
</txp:if_different>
<li><txp:posted format="%B" />: <txp:permlink><txp:title /></txp:permlink> (<txp:comments_count />)</li>
<txp:if_last_article>
</ul>
</txp:if_last_article>

Last edited by els (2008-05-09 21:32:47)

Offline

#3 2008-05-09 21:29:26

Riyonuk
New Member
Registered: 2008-05-08
Posts: 9

Re: Archive Page

That doesn’t work either…

<ul>
</txp:if_different>
<li>May: <a rel="bookmark" href="http://riyonuk.no-ip.org/logbook/blah">blah</a> (0)</li>
</p>
<ul>
</txp:if_different>
<li>May: <a rel="bookmark" href="http://riyonuk.no-ip.org/thehunter/fg">fg</a> (0)</li>
</p>
<ul>
</txp:if_different>
<li>May: <a rel="bookmark" href="http://riyonuk.no-ip.org/thehunter/test">dfg</a> (0)</li>
</ul>

Offline

#4 2008-05-09 21:33:12

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Archive Page

Sorry! I edited my code above, please try again.

Offline

#5 2008-05-09 21:38:07

Riyonuk
New Member
Registered: 2008-05-08
Posts: 9

Re: Archive Page

It works, TXP wise, I’m not sure why, but it works. I don’t like it that I have to resort to hacks to get to work :/

There’s got to be another way…and what exactly does <if_different> mean? If that tag is different from what? Another if_different tag? Or the tag before it? Or is it just magic?

Offline

#6 2008-05-09 21:50:28

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Archive Page

I wouldn’t call this a hack, it’s a workaround :) It’s just the limitation of this combination of tags. Everything in your article form is repeated for each article (unless wrapped in if_first_article or if_last_article), and when you want more than one list, you’d need a tag like <txp:if_first_article_after_last_if_different_tag> to get it to work properly, and unfortunately, it doesn’t exist… yet, you never know, pigs might fly ;)

txp:if_different means “display the value of this field only when it is different from the previous article’s value”. So you have to use sort="posted" in your article tag, otherwise it won’t work.

Offline

#7 2008-05-10 02:22:39

Riyonuk
New Member
Registered: 2008-05-08
Posts: 9

Re: Archive Page

Well I don’t like how I’m limited. I’m just starting out with CMS’s, I’m thinking of writing my own using some Framework. Would that suit me better? I like things my way, no offense :P

Offline

#8 2008-05-10 08:26:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,450
Website GitHub

Re: Archive Page

Riyonuk wrote:

Well I don’t like how I’m limited. I’m just starting out with CMS’s, I’m thinking of writing my own using some Framework. Would that suit me better?

Nothing to stop you making your own. But in TXP there’s almost always more than one way to do things like using rss_suparchive or some of the other ideas in that post. If the core doesn’t offer something to your liking, there are usually plugins that offer the functionality.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

Board footer

Powered by FluxBB