Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-06-28 21:44:27

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

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

Documentation

Version 0.2 available
download

Last edited by swf (2004-07-01 12:54:56)

Offline

#2 2004-06-29 20:02:35

misterk
Member
From: Morris, MN
Registered: 2004-02-24
Posts: 77
Website

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

#3 2004-06-30 12:36:21

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: swf_if_empty

hmm anyone else having a problem – could someone install it to see – it worked fine on my WAMP (laptop) AND LAMP servers

Offline

#4 2004-06-30 14:22:35

misterk
Member
From: Morris, MN
Registered: 2004-02-24
Posts: 77
Website

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

#6 2004-07-01 12:53:36

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: swf_if_empty

I’m not sure why it wasn’t working but v2 should work now. I rewrote it arfter looking at some of the other plugins that have been written

Can you try v0.2 andsee if it works now?

download

Sorry

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

#9 2004-07-10 15:50:42

jdueck
Plugin Author
From: Minneapolis, MN
Registered: 2004-02-27
Posts: 147
Website

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

#11 2004-07-23 22:02:30

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

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

#12 2004-07-24 16:38:34

kennethlove666
Member
From: arkansas
Registered: 2004-04-27
Posts: 107
Website

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

Board footer

Powered by FluxBB