Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-03-22 00:09:22

yotiao
Member
From: UK
Registered: 2009-10-27
Posts: 28
Website

conditional tags on chh_article tag and other stories

Hello again,
this is what I try to do.

<txp:article_custom>
		<txp:if_article_section name="shorts">
				<div class="short-post">
				<h3><a href="<txp:custom_field name="url" />"><txp:title /></a> <a href="<txp:permlink />">∞</a></h3>
				<p class="meta"><txp:posted /></p>
				<txp:body />
				</div> <!-- /short-post -->

		<txp:else />

			<div class="long-post">
				<h2><txp:title /> <a href="<txp:permlink />">∞</a></h2>
				<p class="meta"><txp:posted /></p>
				<txp:body />
			</div> <!-- /long-post -->
		</txp:if_article_section>
</txp:article_custom>

I have two sections, each using different formats of the posts. On the front page of my blog, I am pulling posts from both sections with their respective formating using article_custom tag. It works like a charm, thanks to some help from fellow forumers :-) However, when I do this, I cannot paginate properly any more. This is a problem.

Since I cannot use the article tag, and I do want to have these two types of content separated, I tried to use chh_article plugin to substitute for the missing functionality of article_custom. But in this case, I do not know how can I use the above conditional statements with chh_article so that it would apply different formatting depending on a section.

So I am a bit lostat the moment and would very much welcome any ideas on how to do multiple section – multiple formatting – type of content pulling with pagination

cheers
yot

Offline

#2 2010-03-22 07:49:19

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

Re: conditional tags on chh_article tag and other stories

yotiao wrote:

I do not know how can I use the above conditional statements with chh_article so that it would apply different formatting depending on a section.

Doesn’t this work?

<txp:chh_article section="shorts,other-section" form="yourform" />

And in ‘yourform’ the code you have now inside the article_custom tags.

Offline

#3 2010-03-22 09:36:20

yotiao
Member
From: UK
Registered: 2009-10-27
Posts: 28
Website

Re: conditional tags on chh_article tag and other stories

Hello, and thanks for the reply!

Unfortunately, this doesn’t work:

<txp:chh_article section="shorts,other-section" form="yourform" />

the output is simply blank. But I found out that this works – sort of –

<txp:chh_article_custom section="shorts,other-section" form="yourform" />

as it outputs what I want (articles from both sections with their respective formatting), but the pagination (with newer/older tags) still doesn’t work (no links are produced whatsoever). Please let me know if I do something wrong.

BTW, I find it curious that I couldn’t put my conditional tags directly inside the chh_article_custom tag, but if I put a form that contains these same conditional statement inside the same chh_article_custom tag, it works. I find it inconsistent ;-)

Anyway, if I am really unable to do this with plugins, I am starting to think that I have to do it differently. Maybe I should use categories instead of sections to divide my content – in principle I can as I don’t use categories for anything, I just thought that sections would be a neater solution (they probably are the proper solution after all). But then what happens when in the future I will have more than 2 categories/sections? Eh.

Just my ramblings ;-)

cheers
yot

Last edited by yotiao (2010-03-22 10:37:16)

Offline

#4 2010-03-22 20:18:29

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

Re: conditional tags on chh_article tag and other stories

yotiao wrote:

Hello, and thanks for the reply!

Unfortunately, this doesn’t work:

<txp:chh_article section="shorts,other-section" form="yourform" />

Sorry, I expected that it would work, but hadn’t tested it.

but the pagination (with newer/older tags) still doesn’t work (no links are produced whatsoever). Please let me know if I do something wrong.

Just like with article_custom, pagination doesn’t work with chh_article_custom. That’s why the chh_article tag was created…

BTW, I find it curious that I couldn’t put my conditional tags directly inside the chh_article_custom tag, but if I put a form that contains these same conditional statement inside the same chh_article_custom tag, it works. I find it inconsistent ;-)

The plugin was written long before the Txp container tags were introduced (4.0.7, november 2008). So, not really inconsistent, this was exactly how the Txp tags worked until then.

Anyway, if I am really unable to do this with plugins, I am starting to think that I have to do it differently.

You can do it of course (but I don’t know if your structure allows it). You said it was for the front page? If these two sections – ‘shorts’ and ‘other-section’ – are the only two for which you set ‘on front page’ to ‘yes’, you can just use the txp:article tag; no need for a section attribute then.

Offline

#5 2010-03-23 10:36:53

yotiao
Member
From: UK
Registered: 2009-10-27
Posts: 28
Website

Re: conditional tags on chh_article tag and other stories

Hello,

You can do it of course (but I don’t know if your structure allows it). You said it was for the front page? If these two sections – ‘shorts’ and ‘other-section’ – are the only two for which you set ‘on front page’ to ‘yes’, you can just use the txp:article tag; no need for a section attribute then.

Yes, I could do that (I actually tried and decided to go with the categories). I have now set up everything with categories and it works! Yeah! My annoying problem is that my vision of the site evolves as I am learning TXP :-) So, for now, I think I will only have these two sections/categories on the front page, but I don’t know what happens in a year or so of my blogging. So I am trying to build in some flexibility into the design now…

Thanks Els for all the help!

cheers
yot

Offline

Board footer

Powered by FluxBB