[pmwiki-devel] Creating Conditions

The Editor editor at fast.st
Wed Nov 15 09:54:32 CST 2006


I've been working on this for hours and have come very close to what I
want...  Basically a conditional I can use to determine if an item is
in a CSV list in a specified data field.

Basically I have a pagelist template like this.

[[#chatmembers]]
TEST:  page=Chatrooms.Test2 list=AdminList name={=$:Member}\\
(:if inlist page=Chatrooms.$room list=AdminList name={=$:Member}:)
* ADMIN: [[Chat.Members?return=$room?room=$room?member={=$:Member}|{=$:Member}]]
(:if ! inlist page=Chatrooms.$room list=AdminList name={=$:Member}:)
* Not admin [[Chat.Members?return=$room?room=$room?member={=$:Member}|{=$:Member}]]
(:ifend:)
[[#chatmembers]]


Here is what I have come up with for the conditional (in the ZAP recipe).

$Conditions['inlist'] = 'InList($condparm)';
function InList($x) {
	$arg = ParseArgs($x);
	$item = $arg[name];
  	$l = explode(",", ZAPgetdata("$arg[list]", "$arg[page]"));
	foreach ($l as $ll) {
		if (strcmp($ll, $item) == 0) return true;
		}
	return false;
	}


I set this up as a chat command temporarily and was able to verify it
seems to work.  That is, by changing the returns to screen messages, I
got the output I wanted (true / false).

But on my actual pagelist in the sidebar, everything returns false.  I
can even cut and paste the test line from the pagelist (the first
line) as a chat command and it returns true.

Am I missing something?  This is the first time I've set up a
conditional, and pretty excited I could get this far.  Next will come
some fancy comparisons of timestamps!  Yeah...  can't wait.

Thanks in advance.

Cheers,
Caveman



More information about the pmwiki-devel mailing list