Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-08-25 11:38:02

grafem
New Member
Registered: 2010-08-25
Posts: 3

How to get section show only one single article?

I’m very new to textpattern and here is a question I haven’t been able to figure out on my own:

My site has header, left sidebar, center div and footer. On my site when I choose one section it displays all the articles written in that section in links. Both in the left sidebar and in the center. How do I get it to display only one particular post in the center div?

example: I have section books under which are book1, book2, book3. When I click books it displays in center the books1-3 in links from which to go to the actual article. How to get it show only content of article book1 in the center div?

I’m using the basic textpattern script, no added plugins or css.

Thanks in advance!

Offline

#2 2010-08-25 13:11:45

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: How to get section show only one single article?

Basically the if/else case always works like this:

<txp:if_article_list>
<!-- code for article list -->
<txp:else>
<!-- code for single article -->
</txp:if_article_list>

Related: if individual article

Check out Textpattern Tag Reference and study the basic template code


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#3 2010-08-25 13:13:11

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: How to get section show only one single article?

  1. You’ll need a default article for your books section in order to display some content in the center div. Set its status to sticky.
  2. Find the article(_custom) tag that creates your article links by e.g. typing some notes immediately above each article tag you find and then calling your page again.
  3. Copy that tag, replace it by the code below and replace the comment (i.e. the <!-- Put the copied article tag from your center div here -->) with the copied article tag.
<txp:if_section name="books">
    <txp:if_individual_article>
        <txp:article />
    <txp:else />
        <txp:article_custom section="books" status="sticky" limit="1" />
    </txp:if_individual_article>
<txp:else />
    <!-- Put the copied article tag from your center div here -->
</txp:if_section>

If you have further sections that shall be treated this way, add their names comma separated to the name attribute of the if_section tag.

EDIT: In order not to puzzle you too much: the if_article_list tag merz1 uses does basically the same as my if_individual_article tag, it’s just that the two yes/no halves are swapped.

Welcome to TXP!

Last edited by uli (2010-08-25 13:22:34)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#4 2010-08-26 08:25:48

grafem
New Member
Registered: 2010-08-25
Posts: 3

Re: How to get section show only one single article?

Thanks uli, it worked! :)

Now I have another question, the article I put to ‘sticky’ which opens directly to center div doesn’t appear anymore in the left sidebar. Is there a way to get it show there too?

Thank you very much for taking time to help me with these probably very elementary issues…I think I’m gradually starting to get to grips with txp
.

Offline

#5 2010-08-26 12:41:09

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: How to get section show only one single article?

Making an article ‘sticky’ takes it out of the normal flow of a pages and generally pins it to a section (so for instance it is not affected by newer documents or such like – like a sticky in a forum). You can however target a sticky article directly by using:

<txp:if_individual_article>
  <txp:else />
    ACTIONS FOR STICKY ARTICLE
</txp:if_individual_article>

You would probably not want to list the sticky article in a navigation list, since it is probably going form part of a section intro page and not be a page on it’s own, so link to the section page instead.

I’d recommend the Textpattern Solutions book which is great for getting your head round how the system works – new tags have been introduced since the book was published but I still find myself flicking through it on a regular basis.

Last edited by philwareham (2010-08-26 12:42:47)

Offline

#6 2010-08-27 01:57:09

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: How to get section show only one single article?

Is there a way to get it show there too?

There are some … umm … not so elegant solutions.
  • You can put an extra article tag for sticky articles in your menu, but as Phil already stated: a sticky is taken out of the article flow, it will not be positioned where an article with status live would be displayed.
  • You can of course put normal HTML code for your link in the sidebar, but likewise only before or after the list.
  • You can even manage to include the link in the list by means of a rah_replace tag, but that’s a fragile solution where you have keep an eye on the menu tree’s content.

And – of course – there’s smd_query whose output I often don’t succed to get tamed ;) as a replacement for all kinds of tags. Which I would not count into the “not so elegant” category.

Last edited by uli (2010-08-27 02:01:39)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#7 2010-08-27 11:58:01

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: How to get section show only one single article?

Shouldn’t <txp:article status="live,sticky" /> work in the left column ? (or article_custom)

Offline

#8 2010-08-27 12:14:14

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: How to get section show only one single article?

CeBe wrote:

Shouldn’t <txp:article status="live,sticky" /> work in the left column ? (or article_custom)

No, they both don’t accept two values. I’ve changed the wiki entries last night to make this a little clearer (comma to “or”).


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#9 2010-08-27 12:47:10

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: How to get section show only one single article?

uli a écrit:

No, they both don’t accept two values. I’ve changed the wiki entries last night to make this a little clearer (comma to “or”).

Ah … ok. Much better this way.

Offline

#10 2010-08-30 06:09:36

grafem
New Member
Registered: 2010-08-25
Posts: 3

Re: How to get section show only one single article?

I solved this last question by using id <txp:article_custom section=“xx” id=“xx” limit=“1” />
instead of status=“sticky”

Seems to be working, now the same article appears in the left sidebar and in the center.

Thanks all for your help!

Offline

Board footer

Powered by FluxBB