Textpattern plugin : ajw_if_comment_owner

09 March 2005 @ early morning | Comments (17)

Plugin Details

Download:
ajw_if_comment_owner
Version:
0.3.1
Forum:
Read discussion
Status on this site:
Active

Please use forum for all bug reports and questions

Summary

Conditional output based on comparing the name of the commenter with either a) the real name of article author or b) with a user-specified name (or comma-separated list of names). In the future, I plan to allow for checking email and URL as well. Intended usage is from within default comment form.

Attributes

name
name="Mr. T"
name="Mr. T, Dean Allen"
email
email="nobody@example.com"
email="nobody@example.com,somebody@example.com"
web
web="example.com"
web="example.com,example.net"
strict (optional)
Setting this value to "1" will allow for more strict checking of name/email/web combinations. If strict mode is enabled, one item of each specified comment attribute must match.
Default: 0 (false)
<else />
(optional) Anything output below this point will be output in the event of a false/negative check

Examples

Ideally, this is meant to be used in your default comment form. While it is possible to use this plugin with the default <ol> formatting of comments, you’ll be able to do much more fun things if you switch off numbered list formatting in admin -> preferences.

This tag is intended to be used as an “enclosure” tag, meaning it should enclose text that will be conditionally displayed based on the rules you set. For example:

<txp:ajw_if_comment_owner name="foo,bar">
    owner
</txp:ajw_if_comment_owner>
<txp:ajw_if_comment_owner name="tom,sue">
    friends
</txp:ajw_if_comment_owner>

Here are some example attribute combinations with evaluated meaning:

  • name="foo"
    anyone named “foo”
  • name="foo,bar" email="foo@domain.com"
    (foo OR bar) OR foo@domain.com
  • name="foo,bar" email="foo@domain.com" strict="1"
    (foo OR bar) AND foo@domain.com
  • name="foo" email="foo@domain.com" web="domain.com" strict="1"
    foo AND foo@domain.com AND domain.com
  • name="foo,bar" email="foo@domain.com" web="domain.com" strict="1" (foo OR bar) AND foo@domain.com AND domain.com

Revision History

  • v0.3.1
    • Fixed typo in “help” documentation
  • v0.3
    • Added ability to use “else” clause
  • v0.2
    • Allows for strict or loose checking of multiple fields

17 comments

1

Great work! I would like to see comparsion with email in further versions, then this field could be used like a “secret password”.

Johan Nilsson → johan.galaxen.net
2

Very cool plugin, thank you! :-)

One thought I have is it would be great if it worked in a similar way to the if_category plugin… you could have some real fun with regular site visitors then! :-)

John Oxton → joshuaink.com
3

Interesting suggestions – I’ve been buried the last couple days and haven’t been able to get back to the blast of plugins I released last week.

@Johan – yes, agreed. I am currently working on a much-expanded version.

@John – I think what you’re describing is possible if you use multiple tags. You could chain them together, effectively creating an if/elseif (currently only name-based).

It’ll be much easier and sexy when I release the next version, so you can check email addresses etc. But for now you can use:

<txp:if_comment_owner name="andrew">owner</txp:if_comment_owner>
<txp:if_comment_owner name="john oxton,johan nilsson">friend</txp:if_comment_owner>

andrew → compooter.org
4

Excellent stuff, thanks for the tip :-)

John Oxton → joshuaink.com
5

I might be missing something, but what about the “rest”? If I’m to have something for the ones that don’t match up at all?

Andreas Kofstad → andreas.comart.no
6

Good stuff andrew, this and the comment number will make life so much easier!

jamie
7

Andreas :: I’m currently looking into adding an else feature & am ironing out how it would/should work.

andrew → compooter.org/
8

ok, Andreas – it now allows for “else” conditional tags.

andrew → compooter.org/
9

I’m not really sure why, but when I try and use this tag it breaks my comments. Can you give an actual example of how the commet form would look.

Cody Lindley → codylindley.com
10

It seems unless I use the else part the tag breaks my comments on the first comment that is an author comment.

Cody Lindley → codylindley.com
11

Hmm… could be a logic error. I’ll investigate.

I’m going to move this discussion back over to the Textpattern forum so that there is a centralized discussion.

andrew → compooter.org/
12

This dark grey is a resultat of your ajw_if_comment_owner-Plugin?

Nick Blume → guillemets.de
13

Yes – it adds an additional class="andrew" to my comments.

Andrew → compooter.org/
14

Well, it´s done on my site! See here at the comments (»Kommentare«).

Nick Blume → guillemets.de
15

what an awsome plugin! Thanks for all the hard work. It works like a charm.

Gordon Brander → gordonbrander.com
16

Is it possible to use multiple “Else” clauses to conditionally format various peoples’ comments? I’m not finding a way to make it work.

benny → kingbennymusic.com
17

And by the way, I really do like the plugin – great job.

benny → kingbennymusic.com

Comments are closed for this article.

Previously

Elsewhere