Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-11-27 23:44:29

jackson
Member
Registered: 2005-10-01
Posts: 14

Custom Fields and Categories

Here is what I am trying to do.

I have two categories, Cat1 and Cat2. I have 2 Custom Fields, Custom1 and Custom2.

On the main default page, I would like all posts in both categories displayed, which it does. I would also like the contents of Custom1 and Custom2 displayed on the default main page. That works fine with default txp.

However, when one navigates to Cat1, i.e., domain.com?c=cat1 or using clean urls like domain.com/category/cat1, I would like the posts in Cat1 displayed with only the contents of Custom1 displayed. Likewise, when one navigates to Cat2, I would like the posts in Cat2 displayed with only the contents of Custom2 displayed. It tried using nested <txp:if_category> tags but they did not work so well, thinking it would be like “if cat1, then show custom1, else, if cat2, then show custom2, else show custom1 and custom2” but that did not work.

Any guidance would be most appreciated. Thank you.

Offline

#2 2006-11-28 01:31:39

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Custom Fields and Categories

So this doesn’t work? What is your default page template and article forms used?

<txp:if_category>
	<txp:article form="cat_list" limit="999" />
<txp:else />
	<txp:if_search>
		<!--We are searching-->
		<txp:article form="search_results" limit="9999" />
	<txp:else />
		<!--We are on the homepage-->
		<txp:article/_custom ... />
	</txp:if_search>
</txp:if_category>

form: cat_list

<h2><txp:title /></h2>
	<txp:excerpt />
	<txp:custom_field name="custom1" />

You might need to uncheck “Automatically append comments to articles” in Admin>Prefs>Site.

Last edited by jm (2006-11-28 01:33:06)

Offline

#3 2006-11-28 13:53:52

jackson
Member
Registered: 2005-10-01
Posts: 14

Re: Custom Fields and Categories

Thank you, that does seem to work pretty well. I am just using the default templates at this time. Thanks again!

Offline

Board footer

Powered by FluxBB