Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-03-21 09:53:47

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

txp:if_custom_field Frustrations

Here’s my situation: I have a web site made up of several “static” pages, each of which is created by using txp:article to pull the one article in that section. I want to be able to show the excerpts from one or two of these articles on the front page, possibly rotating which articles appear there, but without causing them to stop displaying on the “static” section pages. I don’t want to have to alter my template every single time I change what’s on the front page.

I’m trying to manage this with the “sticky” article status. What I want is for the front page to display excerpts of any and all sticky articles, sorted by custom_5 and using a special title stored in the “Front_Page_Title” custom field. Since the status attribute of txp:article doesn’t seem to take comma-seperated values, I’m trying to choose the status of articles displayed on child pages based on the presence or absence of the “Front_Page_Title” custom field. Here’s the code:

<pre><code>&lt;txp:if_section name=”“&gt;
&lt;txp:article form=“front_page” sortby=“custom_5” sortdir=“asc” status=“sticky”/&gt;
&lt;/txp:if_section&gt;

&lt;txp:if_section name=“about”&gt;
&lt;txp:article limit=“1” form=“about” status=“sticky” /&gt;
&lt;/txp:if_section&gt;

&lt;txp:if_custom_field name=“Front_Page_Title”&gt;
&lt;txp:article limit=“1” form=“child_pages” status=“sticky” /&gt; &lt;txp:else /&gt; &lt;txp:article limit=“1” form=“child_pages” /&gt;
&lt;/txp:if_custom_field&gt;</code></pre>

“About” has its own form and its own conditional statement because of some special things that need to appear on that page. It works just fine. The if_custom_field conditonal, however, returns “false” even on pages where it should be returning “true.”

Here’s the tag trace. Can anyone tell me what I’m doing wrong?

Offline

#2 2006-03-21 10:10:07

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: txp:if_custom_field Frustrations

I finally caved and created another page template for the About section, which solved my problem. I’d still be interested in knowing why I was getting such strange results, however.

Offline

#3 2006-03-21 11:00:14

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: txp:if_custom_field Frustrations

if_custom_field is valid in an article context (inside an article form like your child_pages, for instance), not in the page context (which custom field should Textpattern choose there?)

//w&

Offline

#4 2006-03-21 15:00:54

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: txp:if_custom_field Frustrations

Thanks for the reply, wet.

I thought of that, and tried putting it in the article form instead. That didn’t work either, though, and it was at that point that I made another page template. Another template was really the best solution all along, since it keeps things simpler. Part of my brain still seems to be fighting against the “Textpattern way” for some reason. :)

Offline

Board footer

Powered by FluxBB