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: 741

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: 741

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

Board footer

Powered by FluxBB