Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
if_custom_field hiccups
The following code sometimes works and sometimes not (?!?):
<pre>
<txp:ign_if_not_logged_in>
<txp:if_custom_field name=“Normal Price”>
<span class=“price”>£<txp:custom_field name=“Normal Price” /></span>
</txp:if_custom_field>
</txp:ign_if_not_logged_in>
<txp:ign_if_logged_in>
<txp:if_custom_field name=“Dealer Price”>
<del><span class=“price”>£<txp:custom_field name=“Normal Price” /></span></del>
<span class=“price”>£<txp:custom_field name=“Dealer Price” /></span>
<txp:else />
<span class=“price”>£<txp:custom_field name=“Normal Price” /></span>
</txp:if_custom_field>
</txp:ign_if_logged_in>
</pre>
Any ideas?
Last edited by gerhard (2006-04-04 17:17:23)
Offline
#2 2006-04-04 19:32:58
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_custom_field hiccups
Are you using the above within an article form and calling it with the article tag?
Offline
Re: if_custom_field hiccups
Yes Mary, I’m using it in an article form and calling it like this <code><txp:article form=“shop_single” limit=“10” listform=“shop_list” /></code>.
What vexes me is that for some articles it displays the custom fields and for others it doesn’t (all of them have data in custom fields).
Cheers Mary, Gerhard.
Offline
Offline
#5 2006-04-12 05:09:45
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_custom_field hiccups
I’m not sure. A stab in the dark: maybe it’s because of listform (no, it shouldn’t do that). What happens if you replace the above with:
<txp:if_individual_article>
<txp:article limit="10" form="shop_single" />
<txp:else />
<txp:article limit="10" form="shop_list" />
</txp:if_individual_article>
Anything change?
Offline
Re: if_custom_field hiccups
There may be two issues according to your code:
1. If not logged in and there’s no “normal price” custom field, nothing is output.
2. If logged in and there’s no “dealer price” and no “normal price” custom field, nothing is output, either.
Offline
Re: if_custom_field hiccups
Yes Mary, you were right, now it works. Getting my head around those conditionals I suppose… : ).
Since we’re already @ it, I have this other grief. It’s a misc article form:
<pre>
<txp:if_section name=“archives”>
<?php if ($_GET[‘by’] == ‘cat’) { ?>
<txp:rss_suparchive_bycat section=“blog” linktosection=“blog” />
<?php } else if ($_GET[‘by’] == ‘date’) { ?>
<txp:rss_suparchive section=“blog” linktosection=“blog” datesep=” » “ showdate=“1” />
<?php } ?>
<txp:else />
<txp:if_individual_article>
<txp:article limit=“1” />
<txp:else />
<txp:php>if ($GLOBALS[‘c’]) { article(array(“limit”=>“10”)); } else { article(array(“limit”=>“3”));}</txp:php>
</txp:if_individual_article>
</txp:if_section>
</pre>
Everything is fine until it hits the <code>article()</code> bit. As you could imagine, there is no output on the page. Am I missing something (again)?
Last edited by gerhard (2006-04-12 08:33:02)
Offline
#8 2006-04-13 03:12:48
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_custom_field hiccups
You need to have those functions echoed: echo article(array("limit"=>"10"));
, and so on.
Offline
Offline
#10 2006-04-14 04:55:56
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_custom_field hiccups
Because that’s the nature of the return statement. :)
Offline
Offline
Pages: 1