Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2006-01-20 00:54:05

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

Re: One Page (template) to rule them all

@doggiez: Unfortunately, just using <code><txp:article ></code> doesn’t work. I see what your line of reasoning is, but there’s apparently something missing with respect to parsing the articles to the right Section.

doggiez wrote:

It doesn’t??? I really thought that when you’re on a section page, <txp:article /> would show only articles in that section… and since you can only be in one section at the time I assumed this would work. If I understood your explanation correctly, we’re not even on an individual article page, but on the section homepage. So I wonder why it doesn’t work.
Well, one is never too old to learn ;) (And of course I didn’t try this before posting…)

I’m with you, doggiez. That should work… why it isnt working? Maybe a bug in 4.0.3? (I havent tested 4.0.3. yet)
Or maybe things have changed? or maybe am I wrong? (also very probably)

<blockquote><code>
<txp:if_section name=“section1,section2”>
<txp:if_article_list>
<txp:article listform=“title” />
</txp:if_article_list>
</txp:if_section>
</code>
</blockquote>

This also seems to be redundant and ineffective (well, maybe not for Destry’s purpose, and this thread is about what Destry needs) if we consider that just putting txp:article should work…

Txp:article is context-sensitive. It should “know” when it is in an article-list context (so, it will use the form specified in “listform” attribute) or in an individual-article context (it will use the form in “form” attribute).
So you can create a form for “listform” attribute including the article tags you need, and also an empty form for “form” attribute… So… if I’m not wrong, when in individual-article context, it shouldnt display anything…

Last edited by maniqui (2006-01-20 00:54:39)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#17 2006-01-20 09:48:59

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

Re: One Page (template) to rule them all

I’m with you, doggiez. That should work… why it isnt working? Maybe a bug in 4.0.3? (I havent tested 4.0.3. yet)
Or maybe things have changed? or maybe am I wrong? (also very probably)

No you’re right, it works. Even without the <txp:if_article_list>, but only on an article list page. If you’re on an individual article page it displays just the main article again. That’s why I added <txp:if_article_list>, but this solution of yours

So you can create a form for “listform” attribute including the article tags you need, and also an empty form for “form” attribute… So… if I’m not wrong, when in individual-article context, it shouldnt display anything…

is much better. Very clever!

Offline

#18 2006-01-20 10:21:17

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

Re: One Page (template) to rule them all

maniqui wrote: This also seems to be redundant and ineffective (well, maybe not for Destry’s purpose, and this thread is about what Destry needs) if we consider that just putting txp:article should work…

I guess I failed to express myself clearly. I want to approach this efficientlly and effectively, and that includes using the Tags in the best (lightest) way possible.

Now, I think you guys are saying something good, but I’m not sure it’s in context to the real setup at hand. Can you keep it on target and not get abstract. Remember, I have a main reading section and a sidebar. The sidebar is a list of articles (titles only) that are tied to a category. The articles themselves are tied to a given Section, but we’re shooting to have the same Page for all views.

You folks are talking about “page lists” and single article pages as if they are something separate, I think. I want them both in the same Section view, while parsing the different categorized articles accordingly in the sidebar from Section to Section.

If I don’t have to use the <code><txp:if_article_list>…</code> Tags great, but if that’s the only way to do it I will . If there’s a better (less redundant way), great, I would rather go there. So what is it, exactly?

Ideas expressed with code snippets rather than abstract discussion are better in this case, thank you. (Oh, and show code snippets that do work, not the ones that don’t work.)

Last edited by Destry (2006-01-20 10:26:13)

Offline

#19 2006-01-20 10:31:40

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

Re: One Page (template) to rule them all

Okay, so this works in the sidebar too, and parses the articles as desired…

<div id="sidebar">
<txp:if_section name="section1,section2,section3,section4">
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
<txp:else />
<txp:output_form form="mSearch" />
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
</txp:if_section>
</div>

But what about the comments problem Stuart was talking about? See reply boxes #13 and #14 above for the situation and the code I was asking about.

Last edited by Destry (2006-01-28 09:47:02)

Offline

#20 2006-01-20 17:57:32

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

Re: One Page (template) to rule them all

Unless someone confirms or denies it Destry, and as it’s for a local install, I would suggest the quickest way to find out is to try it. If you end up with a comment_form in your sidebar in individual_article view then you know you can’t use “article”.

I’m a little vague about this as there have been so many changes recently. For example, I know there was a problem with paging and splitting up your articles like:-

article
advert
article
advert

and changes were made to “pageby” to allow for this so maybe other changes were made which would allow more than one article tag in “normal” layouts. Or maybe the kind of structure above can only be used when “auto append” is off. It’s just impossible to remember everything isn’t it? Sorry if this is abstract but I’m trying to explain why I’m not sure if using 2 article tags is a problem or not.

EDIT

Talk of the devil, here’s someone having exactly the problem I mentioned.

Last edited by thebombsite (2006-01-20 18:21:45)


Stuart

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

Offline

#21 2006-01-20 18:01:35

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

Re: One Page (template) to rule them all

> Destry wrote:

> Okay, so this works in the sidebar too, and parses the articles as desired…

<code><div id=“sidebar”>
<txp:if_section name=“section1,section2,section3,section4”>
<txp:output_form form=“mHeader” />
<txp:article listform=“alstDefault” limit=“5” />
<txp:else />
<txp:output_form form=“mSearch” />
<txp:output_form form=“mListHeader” />
<txp:article listform=“alstDefault” limit=“5” />
</txp:if_section>
</div></code>

Hi Destry. You can also do:

<div id="sidebar">
<txp:if_section name="">
<txp:output_form form="mSearch" />
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
<txp:else />
<txp:output_form form="mHeader" />
<txp:article listform="alstDefault" limit="5" />
</txp:if_section>
</div>

It’s the same, but “al revés” (dont know how to say it in english… ¿“turned to the other side”?)
This way, if you create a new section in your site, you dont have to worry about adding its name to the “name” attribute. It’s a bit lighter and more effective.

But wait! We can even go more far. Try if this works for you:

<div id="sidebar">
<txp:if_section name="">
<txp:output_form form="mSearch" />
<txp:output_form form="mListHeader" />
<txp:else />
<txp:output_form form="mHeader" />
</txp:if_section>
<txp:article listform="alstDefault" limit="5" />
</div>

The code has been reduced a bit… it’s even lighter!

maniqui wrote:

So you can create a form for “listform” attribute including the article tags you need, and also an empty form for “form” attribute… So… if I’m not wrong, when in individual-article context, it shouldnt display anything…

Doggiez said that one is clever! So, in a code snippet, that should be:

<code><txp:article listform=“alstDefault” form=“empty” limit=“5” /></code>

And the “empty” form should be empty.

Destry wrote:

p. But what about the comments problem Stuart was talking about? See reply boxes #13 and #14 above for the situation and the code I was asking about.

I’m not very familliar with comments, and how they work. But I would go with the “auto append switched off” suggestion.
But, now I’m noticing that with the above snippets, you wont get anything in the sidebar, when in individual-article context…

Finally, Destry, I’m not sure if I have totally understood your request.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#22 2006-01-20 18:24:10

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

Re: One Page (template) to rule them all

You guys are great. Didn’t mean to sound testy…sometimes I try and zero in on things too hard.

Stuart’s right, just need to try some things, and maniqui, those are good code reduction suggestions.

That bit in box 14 above (having to do with the php code) is looking ahead of the curve (I thought that was what Doggiez was referring to earlier on), in case there is a problem as is with comments showing up in the sidebar.

It’s local, yes, but again, I do want this to be practical for live use as well, not necessarily mine. (Trying to think outside the box) ;)

Thanks for your very insightful and welcome feedback. I’ll report back if I learn something.

Offline

#23 2006-01-20 19:05:28

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

Re: One Page (template) to rule them all

maniqui wrote:

But, now I’m noticing that with the above snippets, you wont get anything in the sidebar, when in individual-article context…

That’s when a nice plug-in like rdt_dynamenus can do the job easily.
From the help of rdt_dynamenus:

Tag: rdt_article_menu
The rdt_article_menu tag retrieves a list of article permlinks assigned to the current section. It generates an HTML list and marks the current article with class=’active’.
It’s less flexible than the built-in article_custom tag but much simpler.

So, you can have something like this:

<code><div id=“sidebar”>
<txp:if_section name=”“>
<txp:output_form form=“mSearch” />
<txp:output_form form=“mListHeader” />
<txp:else />
<txp:output_form form=“mHeader” />
</txp:if_section>
<txp:rdt_article_menu wraptag=“ul” break=“li” />
</div></code>

That should work in any context and will be section-sensitive.
It’s easier than the PHP solution, at least, for me.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#24 2006-01-28 10:15:15

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

Re: One Page (template) to rule them all

Maniqui, thanks for your feedback on this.

I have to apologize. I found some errors in the Tag snippets I posted earlier (in actuality, the <code>mHeader</code> and <code>mListHeader</code> were the same thing, namely <code>mListHeader</code>). I since fixed them in my posts, but your suggestions now don’t reflect the actual code, so I’m not sure if what your suggesting is still correct. Again, sorry.

Based on some of your other good ideas, here’s how it stands at the moment (this works fine for single Categories associated to each Section)…

<div id="sidebar">
<txp:if_section name="">
<txp:output_form form="mSearch" />
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
<txp:else />
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
</txp:if_section>
</div>

(I haven’t accounted for multiple — at least 2 — Categories in each Section appearing as separate lists in the sidebar for that given Section; that’s a trick for later.)

I think what you were suggesting with your second block of code in reply #21 above was to somehow represent <code>mListHeader</code> only once (since it’s the same on both sides of the conditional), right?

(For our viewing audience at home who is now thinking, “hey, the <code><txp:article listform=“alstDefault” limit=“5” /></code> is on both sides of the conditional too so why aren’t you taking that into account? Because the respective article output will be tied to their representative Sections so even though it looks like the same output from the code, it really won’t be. The <code>mListHeader</code> Form, on the other hand, is a custom Form that defines the exact same header in all instances so that part of the formula could be reduced somehow, at least that’s the idea…whether or not it’s actually possible in a manner more reduced than above.)

I haven’t yet tested the comments behaviors as talked about earlier, but I will when I get time and report back.

Last edited by Destry (2006-01-28 10:31:02)

Offline

#25 2006-01-28 13:37:39

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

Re: One Page (template) to rule them all

> Destry wrote:

<div id="sidebar">
<txp:if_section name="">
<txp:output_form form="mSearch" />
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
<txp:else />
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
</txp:if_section>
</div>

I think what you were suggesting with your second block of code in reply #21 above was to somehow represent <code>mListHeader</code> only once (since it’s the same on both sides of the conditional), right?

maniquí thinks: “hey, the <code><txp:article listform=“alstDefault” limit=“5” /></code> is on both sides of the conditional too so why aren’t you taking that into account?”

;)

Destry wrotes:

Because the respective article output will be tied to their representative Sections so even though it looks like the same output from the code, it really won’t be.

Really? Txp:article is context-(section)-sensitive. And thinking loud: how is it possible that the output is different if it is inside or outside a conditional (if in both sides of the conditional)?
I cant see that in my mind.

I insist with this new snippet:

<div id="sidebar">
<txp:if_section name="">
<txp:output_form form="mSearch" />
</txp:if_section>
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
</div>

That means: “if we are in section default (home page), output the “mSearch” form, and also the “mListHeader” form followed by a article list using “alstDefault” as listform. So, when not in section default, that snippet will simple output the “mListHeader” form followed by a 5 article list using “alstDefault” as listform.

As you said, for me, “it looks like the same output from the code” or am i totally wrong?

I haven’t yet tested the comments behaviors as talked about earlier, but I will when I get time and report back.

That, an also the problem of when you are in an individual-article context, because each “txp:article” tag will output data from the current viewed article.
Maybe, you can try:

  • the idea of an empty form for the “form” attribute (see above) (and if you try it, please, tell us if it works).
  • wrap the snippet with <txp:if_article_list>###</txp:if_article_list> , like:
<div id="sidebar">
<txp:if_article_list>
<txp:if_section name="">
<txp:output_form form="mSearch" />
</txp:if_section>
<txp:output_form form="mListHeader" />
<txp:article listform="alstDefault" limit="5" />
</txp:if_article_list>
</div>

So, in an individual-article context, it wont output anything.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#26 2006-01-28 17:17:40

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

Re: One Page (template) to rule them all

LOL…Maniqui schooled me again. See ladies and gentlemen, this is why maniqui is Moderator of the Tag Examples forum.

Actually I think I’ve let this thread get way out of hand. Although each code block that’s been presented up to this point has been getting progressively more refined, and could have useful applications in other ways, nothing to this point works exactly as I was originally setting out to achieve (and I don’t think the empty Form suggestion is what I’m after). Basically, category lists in the sidebar are not behaving as I want, and I think it’s beyond my patience at the moment to try and explain again in another way (I’ve made a couple revisions in my original post, but that’s as far as I’m going).

I am of the mind, for now, that what I was setting out to do is probably not practical, nor is it even looking like it’s possible under the limited conditions I set out to impose. It’s probably easier to just throw in a couple extra Page templates as needed and/or consider a plugin (if one fits the bill) and call it good. As always, if I discover something of relevance, I’ll report it; but this is going on the back burner.

Offline

Board footer

Powered by FluxBB