Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-09-09 11:51:19

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Conditional custom value

Hi all,

I have a problem trying to output info to the front page based on a custom field value. The custom field is called <code>publish_on_front_page?</code> and a value of “yes” or “no” can be entered. However, in most cases it will probably be left blank – this should be interpeted as a “yes” value. I was pretty sure the following would work, but articles with a “no” are still showing up:

<code>
h3>Recent News:</h3><br/>
<txp:if_custom_field name=“publish_on_front_page?” val=“no”>
<txp:article form=“cltc_article_form” listform=“cltc_list_form” limit=“0” status=“live” />
<txp:else />
<txp:article form=“cltc_article_form” listform=“cltc_list_form” sortby=“posted” limit=“10” status=“live” />
</txp:if_custom_field>
</code>
The majority of articles will be on the front page, but there’s quite a lot of schedule info that shouldn’t be. I started the exercise by using “sticky” articles to solve the problem, but I had articles which needed to be in several sections and sometimes they also needed to be front page news.

Has anyone any ideas on where I’m going wrong?

Offline

#2 2006-09-09 12:24:51

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

Re: Conditional custom value

Again: put <txp:if_custom_field> in your article form.
<code>
<txp:if_custom_field name=“publish_on_front_page?” val=“no”>
<txp:else />
your article form’s regular content
</txp:if_custom_field>
</code>
On the page just this:
<code>
<h3>Recent News:</h3><br/>
<txp:article form=“cltc_article_form” listform=“cltc_list_form” sortby=“posted” limit=“10” status=“live” />
</code>

Offline

#3 2006-09-09 12:50:53

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: Conditional custom value

Thanks Els for your help, I’m starting to feel a little stupid now! Still, this is a great way to learn the way TXP needs to work.

One more problem, I’ve adjusted the article form and default/home page and everything seems fine. I’ve then changed one of the schedules to “live” and added “no” to the custom_field, but it’s still appearing on the front page.

Really not sure where to go next!

Offline

#4 2006-09-09 15:41:40

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

Re: Conditional custom value

Just to be sure: you adjusted the right form, didn’t you? The one for the article list: cltc_list_form.

If that’s not the problem, I’m not sure why it doesn’t work. no has to be exactly that, so with No in the field it won’t work. You could also try to remove the question mark from the custom field’s name.

Offline

#5 2006-09-10 18:32:03

decoderltd
Member
From: London
Registered: 2006-06-20
Posts: 248
Website

Re: Conditional custom value

Ahem,
I was working on the wrong form! Thanks for your reply, I’ve adjusted the List Form and it’s working fine now.

Once again, many thanks for your patience and fine coding.

Offline

Board footer

Powered by FluxBB