Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: One Page (template) to rule them all
It’s just something I remember coming across in the forum where someone had used an article tag in the sidebar as well as in the main content area and was certainly getting 2 comment_forms. I can’t remember about the comment listing though the example post that was linked to may not have had any comments yet. I’m pretty sure the end result was to change to article_custom. When you have “auto append” switched off it doesn’t apply as you place the comment and comment_form tags yourself. Confirmation of this from a dev would be nice though. :)
As for not being able to use TXP tags within TXP tags. Damn!! Maybe a request or two? :grin:
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: One Page (template) to rule them all
Thanks for the tip, Stuart, on the attribute defaults, so what you’re saying is simply drop <code>sortby=“Posted” sortdir=“desc” excerpted=“n”</code> from the Tag element? Is there indication in TextBook what is default attributes? That should be there (note to self).
For the record, this little project is for a local installation I use for personal recordings, notes, etc. It will never be a live site or use comments so to that extent we have arrived at the end.
However, my whole intention for this was to pursue it beyond just my needs and think of the bigger picture. Hence, it’s important to me that we figure this out as a potential and viable solution for live sites too where comments will likely be a factor.
I tried switching in the <code><txp:article_custom /></code> tag for just the <code><txp:article /></code> tag in the code shown above in reply box #7, but as expected that put me back to the original conditions (articles not being parsed by Category).
So, the next thing then, if I understand you both correctly is to try this…
<txp:article_custom section="" listform="title" limit="5" />
…where the <code>section=”“</code> is handled using (as per the FAQ Can I use tags within tags?)…
<code><txp:php></code>
<code>echo article_custom(</code>
<code>array(‘section’=>$GLOBALS[‘pretext’][‘s’])</code>
<code>);</code>
<code></txp:php></code>
—
Problem is (and this is where that FAQ fails a bit), I don’t understand enough how to combine those two things as implied. Can you write out a clear example, someone? And then I’ll give it a try. Also, is this meant to go in the sidebar Tags, or the article output in the main area?
Last edited by Destry (2006-01-19 11:07:55)
Offline
Re: One Page (template) to rule them all
Ooo. I’ve not spotted that before Destry and, like you, I don’t know whether it goes inside or outside the tag. Could do with a confirmation on that as well.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
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)
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
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
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
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
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.
Offline
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
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.
Offline
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