Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-01-01 21:54:00

Andrew Ingram
New Member
Registered: 2008-01-01
Posts: 2

Listing all articles in the same section as the current article

Hi all,

I’m new with textpattern, and i’m having a bit of difficulty listing articles how I want to.

When I view a section I can display a list of all live articles for that section easily enough, but I can’t display that same list when you’re actually viewing the articles themselves.

ie:

/section1/ = shows the sticky article for section1 and shows a list of all live articles in section1
/section1/article-title = shows the specified article and also a list of all live articles in section1 (including the one we’re looking at)

I’ve searched around and can’t really find anything that helps.

Thanks.

Offline

#2 2008-01-01 22:00:55

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Listing all articles in the same section as the current article

Create a form called “listarticles” (or whatever you want) with code similar to:-

<li><txp:permlink><txp:title /></txp:permlink></li>

then in your page where you want the list to display:-

<ul><txp:asy_wondertag><txp:article_custom limit="9999" form="listarticles" section="<txp:section />" /></txp:asy_wondertag></ul>

Change the form name to whatever you called it. You will also need to install the asy_wondertag plug-in to allow you to use “tags within tags”.

Last edited by thebombsite (2008-01-01 22:02:57)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2008-01-01 22:37:34

Andrew Ingram
New Member
Registered: 2008-01-01
Posts: 2

Re: Listing all articles in the same section as the current article

Thanks, it works great. Is there not a way to do it without the plugin?

Also, how does article_custom differ from article?

Offline

#4 2008-01-01 22:47:53

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Listing all articles in the same section as the current article

article is context sensitive, i.e pulls articles based on the section it is in. article_custom is not context sensitive, so it can pull articles from any section. However, paging does not work with article_custom.

Offline

#5 2008-01-02 00:26:23

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Listing all articles in the same section as the current article

Thanks, it works great. Is there not a way to do it without the plugin?

  1. You could type the section manually to the <txp:article_custom />
  2. You could turn automatic comments including off in prefs and use <txp:article /> instead of <txp:article_custom />. Then comments / form can be included to the article form with <txp:output_form form="comments_display" />
  3. Or you could use some PHP and have no need for plugin
<txp:php>echo article_custom(
	array(
		'limit' => '9999',
		'section' => section(),
		'form' => 'listarticles',
	));
</txp:php>

Cheers!

Last edited by Gocom (2008-01-02 03:07:02)

Offline

#6 2008-01-02 02:41:03

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Listing all articles in the same section as the current article

Unfortunately TXP won’t allow tags within tags by default so the plug-in has to be used. The only problem with the plug-in is that it doesn’t work under all circumstances though I tend to find that it generally works with article_custom and rarely works with article.

As Jukka suggests you could just type the section name into the tag but then it will only work for that section whereas the method I show will work anywhere. Indeed if you wanted to be even more specific you could add category="<txp:category1 />" which would narrow the selection even further.

As Jonathan states the article tag is context-sensitive so as Jukka suggests again you could use article instead but that will cause problems with comments probably showing up twice which is why you would need to turn automatic comments off in the preferences.

Or you could start learning PHP. :(

Personally I think my method is much simpler, cleaner and more flexible but the choice is entirely yours. :)

Last edited by thebombsite (2008-01-02 02:41:26)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#7 2008-01-03 02:45:14

Rambling
New Member
Registered: 2008-01-03
Posts: 5

Re: Listing all articles in the same section as the current article

thebombsite’s method worked perfectly for me. I want to show the name of the section above the list of links, so I tried using <h3><txp:section /></h3>. This inserted the name of the section, but I’d really like to insert the title of the section since I use section names that are shortened versions of my section titles (which is due to the need to avoid breaking links from the site I’m converting into a Textpattern site). Is there a Textpattern tag to get the title of a section?

Offline

#8 2008-01-03 02:53:17

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: Listing all articles in the same section as the current article

textbook is your friend

specifically, <txp:section title="1" />

Offline

#9 2008-01-03 03:04:08

Rambling
New Member
Registered: 2008-01-03
Posts: 5

Re: Listing all articles in the same section as the current article

iblastoff wrote:

textbook is your friend

Whoops, I guess I overlooked that. Thanks!

Offline

Board footer

Powered by FluxBB