Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-05 11:26:02

rbl
Member
From: Portugal
Registered: 2004-02-25
Posts: 40

list all articles in a section started by the letter A?

Hi!
I was wondering how to make a simple glossary and would like to know if anyone has any idea on how I could list all articles inside a section that start with a chosen letter?

It could work basically as a wildcard search on article title’s only. I would create a list of links in the template, A to Z , each letter linking to the search result of “search.php?q=a*” for example.

Any idea on how I can accomplish it?

Thanks! =)
Ricardo

Offline

#2 2005-12-05 13:43:19

Maleika E.A.
Member
From: Hamburg, Germany
Registered: 2004-12-11
Posts: 39
Website

Re: list all articles in a section started by the letter A?

Hi,

I’ve never tried it, but perhaps this link is a starting point for you.

Regards,

Maleika

Offline

#3 2005-12-05 14:02:45

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

Re: list all articles in a section started by the letter A?

I think there may be an easier way to do it.

  • Use a custom field to store the first character of the article title.
  • Article tag something like <txp:article sortby="NameOfCustomfield asc" form="index" />
  • Then with txp:if_different in the form ‘index’ you should be able to split the output into A, B, C etcetera.

Offline

#4 2005-12-05 15:07:05

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: list all articles in a section started by the letter A?

That’s tedious. So, it should be a computer’s job.

At the worst, some PHP or SQL might do the trick. On the custom field part, for the rest the txp:if_different is perfect for the job.

Offline

#5 2005-12-05 18:51:23

asarbogast
Member
From: Arcata, CA
Registered: 2004-05-21
Posts: 33
Website

Re: list all articles in a section started by the letter A?

I wrote the article linked to above. A couple of points— it was done with gamma 1.19, so I agree that this is not the most efficient way to do it anymore. However, it’s not a tedious as it sounds and it has held up well :). I am just starting to get my mind around <code>txp:if_different</code>. For us the need is to get only the results beginning with a certain letter— a list of everything ordered by letter would go on for miles… Can that be done with <code>txp:if_different</code>?

Offline

#6 2005-12-05 22:24:10

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

Re: list all articles in a section started by the letter A?

What’s so tedious about typing A, B or C in a custom field?

I suppose something like this would display everything on one page, but with navigation:

Form:
<code>
<txp:if_different>
<div id=”<txp:custom_field name=“letter” />”><txp:custom_field name=“letter” /></div>
</txp:if_different>
<txp:title />
</code>
Navigation (I can’t think of anything else than handcoding):
<code>
<a href=”#A”>A</a> | <a href=”#B”>B</a> | etcetera
</code>
But if you want one letter per page I suppose you should use categories instead of custom fields.

Offline

Board footer

Powered by FluxBB