Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-02 08:33:08

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Nav link default: to section, not section/title. Clues?

I frequently use a section-page combo where there is a default article on the page, and a right column with a list of related article titles, and when one is clicked in the list the full article swaps out the default article on the same section-page — (repeating for each article title clicked in the list). When you leave the section-page, and come back again via the primary navigation, you are again at the default article.

Now, in order to make this work, my primary nav link to the default article needs to include the article title (I use the <code>section/title</code> URL scheme), but I would rather have the nav link work/appear as <code>site.tld/section</code> (i.e., without showing the article title, only the section). I want to avoid using a plugin (though if there’s even one that provides this ability, I would gladly like to know what it is).

I’m sure the answer is in front of my face, but it’s eluding me. Any pointers?

One way I tried to work around this is by adding the default article to the section-page as a static/sticky article, but this was causing problems with the article swapping process, because the static article would always remain in view with the swapped article appearing underneath it. With respect to this latter approach, is there a way to use a conditional somehow and still get the end result of using <code>site.tld/section</code> in the primary nav link? I would really love to understand a conditional solution, if it’s even possible.

Thanks for any insight.

Last edited by Destry (2005-11-02 14:57:29)

Offline

#2 2005-11-02 13:00:48

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Nav link default: to section, not section/title. Clues?

I’m not sure if I’m understanding what you are trying to achive, but let’s see. <blockquote>One way I tried to work around this is by adding the default article to the section-page as a static article, but this was causing problems with the article swapping process, because the static article would always remain in view with the swapped article appearing underneath it. With respect to this latter approach, is there a way to use a conditional somehow and still get the end result of using site.tld/section in the primary nav link? I would really love to understand a conditional solution, if it’s even possible.</blockquote>

You said you are trying to avoid using a plug-in.
But the first approach that comes to my mind is using
glx_if plug-in, that has a conditional for if_section_frontpage and if_not_section_frontpage.

So, you will need to do something like
<code>
<txp:glx_if_section_frontpage>
… default article…
</txp:glx_if_section_frontpage>
<txp:glx_if_not_section_frontpage>
<txp:article />
</txp:glx_if_not_section_frontpage>
</code>

I will keep thinking for a solution without using a plug-in.

Saludos!

Last edited by maniqui (2005-11-02 15:27:16)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2005-11-02 14:21:43

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Nav link default: to section, not section/title. Clues?

Yeah, it’s a bit tricky to explain. I think the key is to try and avoid this kind of process to begin with (find better approach), but it seems like standard fair to me.

Anyway, I’ll look into the plugin, thank you. I just like to get what I can from Textpattern itself first, it’s just me, seems more pure that they, and less to worry about in the future. I’ll report if I tackle things.

Oh, and I don’t think all that info is coming through in your box up there; all I see is “… default article…”.

Last edited by Destry (2005-11-02 14:23:08)

Offline

#4 2005-11-02 14:41:02

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Nav link default: to section, not section/title. Clues?

<code>
<txp:if_article_list> <txp:article status=“sticky” />
<txp:else /> <txp:article />
</txp:if_article_list>

<!— sidebar —>
<txp:article_custom …. />
</code>

This shows the sticky article(s) when you access the section page (it’s a list) or for individual articles it uses a plain article-tag. The sidebar with the article-list is done with article_custom.

Did I miss something?

Offline

#5 2005-11-02 14:41:03

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Nav link default: to section, not section/title. Clues?

I’m not sure if that plugin will work or not yet, but before I rule it out, I need some clarification on the <code>glx_if_not_section_frontpage</code> tag. When is a section not a section frontpage? If I’m operating in a section, it’s always going to be the same section/page combo, the only thing that changes is the article (or article list) that happens to be viewed at any given time.

The description for that tag reads…

“Output text if we are not on a sections frontpage but in a section.”

Huh?

And in the given example, line 2 is just as confusing…

  1. <code><txp:glx_if_not_section_frontpage></code>
  2. <code>We are in a section but not on its frontpage</code>
  3. <code></txp:glx_if_not_section_frontpage></code>

I repeat, huh?

Last edited by Destry (2005-11-02 14:41:30)

Offline

#6 2005-11-02 14:46:26

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Nav link default: to section, not section/title. Clues?

Ooooh, thanks Sencer, let me try and digest that a bit and get back to you. With any luck, this might be my big conditional tag understanding breakthrough.

Offline

#7 2005-11-02 15:48:10

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Nav link default: to section, not section/title. Clues?

I was thinking a similar solution to the one that Sencer suggested, but then I lost my internet connection for few minutes.
When I come back, tuc! Sencer had posted my thinkings. Aaaah, it was telepathy.

Thanks, Sencer!

I just want to add:
Destry, when you have this one polished, maybe you will want to add it to the Tag Examples forum.
This is a nice tag example.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#8 2005-11-02 17:50:31

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Nav link default: to section, not section/title. Clues?

Sencer, my good man, that works beautifully. I had to add a couple of things, but this is how it goes for me in one instance…

<code><txp:if_article_list></code>
<code><txp:article status=“sticky” form=“Single” /></code>
<code><txp:else /></code>
<code><txp:article form=“Single” limit=“1” /></code>
<code></txp:if_article_list></code>

Really the only difference was adding the form <code>form=“Single”</code> in both cases of the article.

Now, I’m not exactly sure why you would have selected the <code><txp:if_article_list> … </txp:if_article_list></code>, that is to say, how someone would have known to use it in this case, because I certainly would never in a hundred years have made sense of that if you had not told me (which might be one BIG reason why conditionals are not immediately easy to understand, and therefore really need documented).

However, now having used it as such, I have a theory, maybe you can confirm, or further explain: <strike>The reason <code><txp:if_article_list> … </txp:if_article_list></code> is used in this case is because we know that we do not have a list being used as the desired output (rather in this case I wanted a single default article), so by saying if article list we are able to juggle two kinds of single article displays (the default article and the article pulled from the side column); no lists involved at all (and that’s the whole idea). Right? Wrong? If that’s right, that’s some rather tricky shiza</strike> EDIT2: see Sencer’s clarification below.

maniqui wrote: Destry, when you have this one polished, maybe you will want to add it to the Tag Examples forum. This is a nice tag example.

Maybe Sencer can just move this thread over there, and I’ll write something up proper later for the tag page in TextBook.

—-

EDIT: Well, the pre tag used to work in the forum, I guess not anymore, but I wish it would come back because wrapping all those lines of code in individual code tags sucks!

Last edited by Destry (2005-11-02 18:37:00)

Offline

#9 2005-11-02 18:12:07

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Nav link default: to section, not section/title. Clues?

If you forgive me, I will phrase it a bit differently. ;)

<txp:article /> will – depending on the url – automatically decide whether it will display a list of articles, or whether it will display an individual article. In the early times it was assumed that it is is enough, that you can use form= and listform= to be able to differentiate the two cases (list and individual article). But it turned out, that in some cases it is more comfortable to use just one one-form, but wrap the conditional around the little changes within the form; and additionally the conditionals gave you the chance to use different stuff even outside of the forms that are used to display the articles.

So I always think of the article-conditionals as an “extension” of the form/listform attributes which works in forms as well as pages.

IIRC you cannot use id= with article, only with article_custom. And in your case – if you only have one sticky in that section – it wouldn’t really make a difference. status="sticky" only displays stickys, and if you only have one, well, that’s what you’ll see.

Offline

#10 2005-11-02 18:33:35

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Nav link default: to section, not section/title. Clues?

<txp:article /> will – depending on the url – automatically decide whether it will display a list of articles, or whether it will display an individual article. In the early times it was assumed …

Uhhhhh, OK.

IIRC you cannot use id= with article, only with article_custom. And in your case – if you only have one sticky in that section – it wouldn’t really make a difference. status=“sticky” only displays stickys, and if you only have one, well, that’s what you’ll see.

Ah, righty-O. It still worked (and it wasn’t sticky), but I’ve set things straight as you point out and all is still good. As to not confuse anyone, I’ll edit that post of mine to reflect the sticky issue.

Offline

Board footer

Powered by FluxBB