Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-04-04 17:16:30

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

if_custom_field hiccups

The following code sometimes works and sometimes not (?!?):

<pre>
&lt;txp:ign_if_not_logged_in&gt; &lt;txp:if_custom_field name=“Normal Price”&gt; &lt;span class=“price”&gt;&pound;&lt;txp:custom_field name=“Normal Price” /&gt;&lt;/span&gt; &lt;/txp:if_custom_field&gt;
&lt;/txp:ign_if_not_logged_in&gt;

&lt;txp:ign_if_logged_in&gt; &lt;txp:if_custom_field name=“Dealer Price”&gt; &lt;del&gt;&lt;span class=“price”&gt;&pound;&lt;txp:custom_field name=“Normal Price” /&gt;&lt;/span&gt;&lt;/del&gt; &lt;span class=“price”&gt;&pound;&lt;txp:custom_field name=“Dealer Price” /&gt;&lt;/span&gt; &lt;txp:else /&gt; &lt;span class=“price”&gt;&pound;&lt;txp:custom_field name=“Normal Price” /&gt;&lt;/span&gt; &lt;/txp:if_custom_field&gt;
&lt;/txp:ign_if_logged_in&gt;
</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

#3 2006-04-05 08:47:33

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

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

#4 2006-04-12 04:57:35

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: if_custom_field hiccups

No more input on this one? Is there a link I could follow Mary to find out where I’m going wrong with my current approach? Cheers.

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

#6 2006-04-12 06:06:15

tranquillo
Archived Plugin Author
Registered: 2005-03-07
Posts: 127
Website

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

#7 2006-04-12 08:28:49

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

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> &lt;txp:if_section name&#61;“archives”&gt; &lt;?php if ($_GET[‘by’] &#61;&#61; ‘cat’) { ?&gt; &lt;txp:rss_suparchive_bycat section&#61;“blog” linktosection&#61;“blog” /&gt; &lt;?php } else if ($_GET[‘by’] &#61;&#61; ‘date’) { ?&gt; &lt;txp:rss_suparchive section&#61;“blog” linktosection&#61;“blog” datesep&#61;” &raquo; “ showdate&#61;“1” /&gt; &lt;?php } ?&gt; &lt;txp:else /&gt; &lt;txp:if_individual_article&gt; &lt;txp:article limit&#61;“1” /&gt; &lt;txp:else /&gt; &lt;txp:php&gt;if ($GLOBALS[‘c’]) { article(array(“limit”&#61;&gt;“10”)); } else { article(array(“limit”&#61;&gt;“3”));}&lt;/txp:php&gt; &lt;/txp:if_individual_article&gt; &lt;/txp:if_section&gt;
</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

#9 2006-04-13 07:01:56

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: if_custom_field hiccups

Hmmm, that is strange. article() already uses return so why use echo? Anyways, it did work with print but not with echo. Cheers Mary ; ), Gerhard.

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

#11 2006-04-14 08:11:39

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: if_custom_field hiccups

In UK they call it a lollie. How do they call it in Canada? : )

Offline

Board footer

Powered by FluxBB