Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
swf_if_empty
My first textpattern plugin.
It adds two conditional tags swf_if_empty and swf_if_not_empty that will display elements if a field does or does not contain data
<code>
<txp:swf_if_empty field=“title”>
<p>Untitled</p>
</txp:swf_if_empty>
<txp:swf_if_not_empty field=“title”>
<txp:title />
</txp:swf_if_not_empty>
</code>
The plugin currently works with the title, body, excerpt, category1, category2, and article_image fields.
If Empty does not work with keywords or custom fields
Version 0.2 available
download
Last edited by swf (2004-07-01 12:54:56)
Offline
Re: swf_if_empty
The plugin caused me this error, even though I don’t think I used it anywhere in my pages, I get this error:
[client 24.223.252.22] PHP Fatal error: Cannot instantiate non-existent class: soapclient in /usr/home/kjell/public_html/textpattern/publish.php(769) : eval()’d code on line 189
publish.php:
<pre><code>function plugins()
{
$rs = safe_column(“code”, “txp_plugin”, “status=1”);
if ($rs) {
foreach($rs as $a) {
$plugins[] = $a;
}
$out = join(n.n,$plugins); eval($out); // line 769 } }</code></pre>
I can’t figure out why, but disabling the plugin makes it better.
Last edited by misterk (2004-06-29 20:03:47)
Offline
Offline
Re: swf_if_empty
I don’t know what that was, I just thought I would put it up. It didn’t mess anything up for a little bit, but I checked in the morning and it gave me errors so I just disabled it.
Offline
#5 2004-07-01 12:09:33
- Rufnex
- Archived Plugin Author
- From: Germany, Munich (Bavaria)
- Registered: 2004-06-23
- Posts: 51
Re: swf_if_empty
Hi swf,
the same problem to me:
Parse error: parse error in /…/publish.php(764) : eval()’d code on line 19
any ideas?
Offline
Offline
#7 2004-07-01 17:35:37
- aba
- Plugin Author
- Registered: 2004-04-14
- Posts: 119
Re: swf_if_empty
congrats, seems to work now without an error.
thanks
Offline
#8 2004-07-10 12:06:38
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: swf_if_empty
good day swf
any chance of getting this plugin to work with custom fields? or is there another way in php to get :
< if field not empty >print field contents< / if field not empty >
thanks
(spose I should go look at php docs!)
Last edited by nardo (2004-07-10 12:07:31)
Offline
Re: swf_if_empty
nardo – just use the custom fields plugin:
<b>http://forum.textpattern.com/viewtopic.php?id=2188
</b>
It will output the contents of any of the custom fields: if they are empty, it will just not output anything.
<i>edit: formatting</i>
Last edited by jdueck (2004-07-10 15:51:18)
Offline
#10 2004-07-11 01:21:37
- nardo
- Member
- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: swf_if_empty
thanks cap’n… only I’m using the custom field just a bit different…
I’ve got an article list of media files, displayed in a table – showing duration, the title hyperlinked to a media file URL, the media format and a MORE INFO button with a link to an outside URL (IF ONE EXISTS)
so for that last one:
< a href=“customfield-INFO-URL” > info < /a >I don’t want the “info” to display if there’s no INFO-URL specified
Offline
Re: swf_if_empty
I started using my own plugin for the body of entries but found that none of them are empty because the html_body has || (linebreaks) even when the body is empty if textile is on.
I think i could fix this by adding a strlength parameter to the if empty. (txp:if_not_empty field=“body” minlength=“3”)
Is anyone else having this problem?
Is this the way I should fix it?
Is there a better way to fix it?
Offline
Re: swf_if_empty
swf – i’m using it the same way (checking for body to be empty) and i just found that i have to set textile to be off for the body. it’d be nice to not have to set this, as less savvy people are going to be using the site to enter content.
Listen to Kenneth
Offline