Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
links to articles if more than one
I am sure I’ve come across this before, but when using the txp:article tag or article_custom tag, how do I output a list of links to the articles in a given section for instance if there are more than one, and not if there is only one?
I know I am gonna kick myself when someone says “duH”.
Obviously I can use if_section tags, but I am hoping there is a more finessed way of doing this?
Matthew
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#2 2006-03-01 18:47:47
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: links to articles if more than one
Offset=“1” ?
EDIT: Oh no, I suppose if there are more than one you would want to include the first one too?
Last edited by doggiez (2006-03-01 18:49:18)
Offline
Re: links to articles if more than one
I thought of that Nils, but then I lose that article if there are two.
So a list of two articles will only show a link to the one other, so that when you want to go < back to the previous (first) article, you need to “back button” it, instead of having a link to it.
Know what I mean?
Matthew
Last edited by ma_smith (2006-03-01 18:50:55)
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#4 2006-03-01 18:52:54
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: links to articles if more than one
ma_smith wrote:
I thought of that Nils,
Els. But never mind ;)
Yeah I realized, see my edit. I’ll think about it some more. Nice challenge.
Offline
#5 2006-03-01 19:39:37
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: links to articles if more than one
I don’t understand what you’re after. ?
Offline
Re: links to articles if more than one
Mary, Your spunge bob thing cracks me up.
Here’s what I am trying to do.
In a sidebar: I have <code><txp:chh_article_custom section=”?” limit=“4” listform=“article-list” /></code>
The “article-list” form is a simple unordered list form.
This is a relatively simple site I am designing. More of a brochureware than anything. So some of the sections have maybe 3 articles while others have only one. I am trying to output a list of those three articles if there is three articles and two if there are two, but NONE if there is only one article, as it would be redundant to have a link to itself.
Its a basic navigation set that should exist only when there are two or more articles in the section.
I’ve used chh_article_custom here so that I can get the best of both txp:article and txp:article_custom
Does that makes sense?
:)
matthew
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#7 2006-03-01 19:57:48
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: links to articles if more than one
No idea if it’ll work, but you could try nesting if_first_article and if_last_article (if it’s both first and last, it’s the only one).
Offline
Re: links to articles if more than one
Cool idea, but no go.
Here’s how I tried it: Is this what you had in mind?
<code>
<txp:if_section name=“services,resources,about-us”>
<txp:if_last_article>
<txp:if_first_article>
</txp:if_first_article>
<txp:else />
<div id=“linkbox”>
<ul>
<txp:chh_article_custom section=”?” limit=“4” listform=“article-list” />
</ul>
</div>
</txp:if_last_article>
<txp:article limit=“1” />
</txp:if_section>
</code>
I also tried it the other way around
Last edited by ma_smith (2006-03-01 20:04:31)
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#9 2006-03-01 20:28:30
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: links to articles if more than one
I was thinking a little differently, but I just checked and it doesn’t work either.
Offline
Re: links to articles if more than one
Some thinking outside the box: Are you stuck with sections, or are you also able to use identical categories on all of the articles which have to show up in that list? txp:related_articles
might be useful in the latter case as it shows all but the current article…
Offline
Re: links to articles if more than one
At this point Wet, I’ve not needed to use categories and was generally hoping to not have to use them, to alleviate a step for the end user. Right now its just straight articles assigned to section. txp:related articles would probably work fine if it had a “section” parameter, but nope.
:)
I like thinking outside the box though.
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
Re: links to articles if more than one
> ma_smith wrote:
txp:related articles would probably work fine if it had a “section” parameter, but nope.
As you are the one who is assigning the categories it is perfectly feasible to mirror each section with one category, so related articles are automagically chosen from the same section as there is no other article elsewhere with a matching category (1:1 relation of section:category)
Which throws you back on “how many required inputs can an end user digest?” I think my idea is doomed ;-)
Offline