Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
if_custom_field
Hi,
I’m having a few problems getting a <code>if_custom_field</code> to work. It’s wrapped in a <code><txp:if_article_list></code> tag as shown:
My code is:
<code>
<txp:if_article_list>
<h3>Our Coaches:</h3><br/>
<txp:article_custom form=“cltc_list_form” category=“Coaches” section=“coaching” sortby=“Posted” sortdir=“desc” status=“sticky” />
<br/>
<h3>Coaching Schedule:</h3>
<br/>
<txp:if_custom_field name=“day” val=“Monday”>
<table>
<tr>
<th scope=“col” abbr=“Time”>Time</th>
<th scope=“col” abbr=“Session”>Session</th>
<th scope=“col” abbr=“Coach”>Coach</th>
</tr>
<txp:chh_article_custom listform=“cltc_coaching_table” category=“Coaching-Sessions,Junior-Teams,senior-teams,Club-Play” children=“y” section=“coaching” time=“any” sortby=“custom_7” sortdir=“asc” status=“sticky” limit=“999”/>
</table>
</txp:if_custom_field>
</txp:if_article_list>
<txp:if_individual_article>
<txp:article form=“cltc_article_form” />
</txp:if_individual_article>
</code>
I’m trying to show a table of events for each day (entered in custom field as set to output as a caption), but I’m not getting any output.
The form “cltc_coaching_table” is:
<code>
<caption><txp:custom_field name=“day”/></caption>
<tr>
<td><txp:custom_field name=“start_end_time” /></td>
<td><txp:category1 title=“1” /> <txp:category2 title=“1” /></td>
<td><txp:custom_field name=“fixture_score” /></td>
</tr>
</code>
Can anyone offer any advice?
Offline
#2 2006-09-08 19:59:34
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_custom_field
<txp:if_custom_field> only works in an article form. You could try something like this in your form “cltc_coaching_table” instead:
<code>
<txp:if_different><caption><txp:custom_field name=“day”/></caption></txp:if_different>
<tr>
<td><txp:custom_field name=“start_end_time” /></td>
<td><txp:category1 title=“1” /> <txp:category2 title=“1” /></td>
<td><txp:custom_field name=“fixture_score” /></td>
</tr>
</code>
On second thought, that would give you a problem with sorting the articles I suppose. Maybe this:
<code>
<txp:if_custom_field name=“day” val=“Monday”>
<caption><txp:custom_field name=“day”/></caption>
<tr>
<td><txp:custom_field name=“start_end_time” /></td>
<td><txp:category1 title=“1” /> <txp:category2 title=“1” /></td>
<td><txp:custom_field name=“fixture_score” /></td>
</tr>
</txp:if_custom_field>
<txp:if_custom_field name=“day” val=“Tuesday”>
<caption><txp:custom_field name=“day”/></caption>
<tr>
<td><txp:custom_field name=“start_end_time” /></td>
<td><txp:category1 title=“1” /> <txp:category2 title=“1” /></td>
<td><txp:custom_field name=“fixture_score” /></td>
</tr>
</txp:if_custom_field></code>
… and so on for each day
Last edited by els (2006-09-08 20:01:16)
Offline
Re: if_custom_field
Thanks Els,
That output all info, but unfortunately doesn’t section/caption the table by day. I suppose a work around would be to create a form for each day, but it seems wrong and over complicated!
Offline
#4 2006-09-09 11:49:52
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_custom_field
decoderltd wrote:
but unfortunately doesn’t section/caption the table by day.
It should. You can’t use <caption> more than once in a table, that might be the problem.
Offline
Re: if_custom_field
Thanks again Els,
A form for each day may be the best route in that case.
Offline
#6 2006-09-09 16:09:01
- els
- Moderator

- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: if_custom_field
Something like this?
Listform cltc_coaching_table:
<txp:if_different>
<tr>
<th colspan="3"><txp:custom_field name="day"/></th>
</tr>
<tr>
<th scope="col" abbr="Time">Time</th>
<th scope="col" abbr="Session">Session</th>
<th scope="col" abbr="Coach">Coach</th>
</tr>
</txp:if_different>
<tr>
<td><txp:custom_field name="start_end_time" /></td>
<td><txp:category1 title="1" /> <txp:category2 title="1" /></td>
<td><txp:custom_field name="fixture_score" /></td>
</tr>
Page:
<txp:if_article_list>
<h3>Our Coaches:</h3><br/>
<txp:article_custom form="cltc_list_form" category="Coaches" section="coaching" sortby="Posted" sortdir="desc" status="sticky" />
<br/>
<h3>Coaching Schedule:</h3>
<br/>
<table>
<txp:chh_article_custom listform="cltc_coaching_table" category="Coaching-Sessions,Junior-Teams,senior-teams,Club-Play" children="y" section="coaching" time="any" sortby="custom_7" sortdir="asc" status="sticky" limit="999"/>
</table>
<txp:else />
<txp:article form="cltc_article_form" />
</txp:if_article_list>
(though I think you shouldn’t have status="sticky" in the <txp:chh_article_custom /> tag)
Offline
Re: if_custom_field
That works like a dream Els! Much more elegant than a load of forms.
Many thanks for all your help, I must read up more on the <code><txp:if_different></code> tag – it looks very useful.
Offline
Pages: 1