This snippet is now deprecated...
use Jot instead: http://modxcms.com/Jot-998.html
Hi,
I created a 'new' snippet for the handling of user comments. It's based on UserComments and some of the original code is still there.
What this snippet does differently is that it stores the comments into an XML formatted document (saved as a child document of the original article). This way it keeps design seperate from the comment data and you can change design at a later stage. The snippet includes a pure code php XML class so you don't need to have an XML DOM enabled php installation to run the snippet.
Also because I use XML it's a small step to AJAX-enabling this snippet and I'm working on that right now for a future version.
The future version will be a complety rewritten piece of code but I wanted to share my snippet somewhat sooner so here it is (I credited the original authors of UserComment and the additional hacks)
Features:* Enable users to post comments (access for posting controlled by specifying webuser groups or allow all)
* Subscriptions (subscribers receive e-mail when a new comment is posted, only available for logged in users)
* CAPTCHA enabled (anti-spam)
* Pagination
* Moderation (managed by webuser groups you specify)
* Uses chunks/templates for styling in combination with the TinyButStrong plugin.
* Use comment count in other snippets (ea. Ditto)
* Enhance comment system with custom fields!
Setup:1) Download and extract the archive.
2) Create a directory called "replix" in your [MODx Directory]/assets/snippets directory
3) FTP or copy the files into [MODx Directory]/assets/snippets/replix
4) Create a new snippet in the manager called "Replix" and copy/paste the contents of replix.snippet.txt into the code field.
Run snippet with:
[[Replix? &makefolder=`1` &customfields=`name,email` &customname=`name`]]Changelog: * June 19, 2006 -- version 1.7.5
- fix: moderator not deleting when logged as a manager user
- fix: poster name not showing in subscription e-mail
- added: author row example to comment.inc.html
- added: replix.css with css styles available when using the default templates
This snippet now requires the TinyButStrong plugin for templating (plugin) !
The next release will make it optional again.
There have been
MAJOR changes to the default templates so please check this before updating ( there are only 3 templates now)
To make this snippet work out of the box (with the default guest form fields) you have to add:
&customfields=`name,email` &customname=`name` to the snippet declaration.
Parameters: &mode (optional)
Set to "
comments.count" and use
&docid to return the comment count for that document.
default: enable comments
&subscribe true | false (optional)
Allow subscribers (notify on new comments).
default: false
&captcha 0 | 1 | 2 (optional)
enable CAPTCHA verification.
0 = disabled
1 = always enabled
2 = enabled when poster is not logged in
default: disabled
&pagination # (optional)
enable pagination for comments
0 = disabled
# = number of comments per page
default: disabled
&canmoderate (optional)
comma delimitted web groups that can moderate comments (delete only).
default: only manager users
&canpost (optional)
comma delimitted web groups that can post comments.
default: allow everyone to post
&canview (optional)
comma delimitted web groups that can view comments.
default: public viewing
&badwords (optional)
comma delimited list of words not allowed in post.
default: none
&makefolder 0 | 1 (optional)
set to 1 to automatically convert the parent document to a folder.
default: 0
&folder id (optional)
folder id where comments are stored.
default: current document id
&docid id (optional, when &mode is used this parameter is mandatory)
document id to use where comments are stored.
use for "remote comment displays"
default: current document id
&tagid tag (optional)
a unique id used to identify or tag user comments on a page where multiple comments are required.
default: -
&freeform 0 | 1 (optional)
set this option to 1 to use the [+ReplixForm+] placeholder to relocate the comment form.
0 = disabled
1 = enabled
default: 0
&sortorder 0 | 1 (optional)
Sort the comments in either
0 = ascending order
1 = descending order
default: descending (1)
&tplComment chunkname (optional)
chunk containing the comment template (html)
&tplForm chunkname (optional)
chunk containing the form template (html)
&tplNotify chunkname (optional)
chunk containing the email notification template (txt)
&customfields (optional)
comma seperated list of custom form field names
default: -
&customname (optional)
name of the form field which represents the name of the poster in guest mode
default: -
&guestname (optional)
display name of a guest when there is no custom name field or this field is left empty
default: Anonymous
Placeholders: Replix drops the following placeholders in the document:
| Standard | TBS Plugin equivalent | |
| [+ReplixForm+] | [{ph.ReplixForm}] | (if freeform is enabled) |
| [+ReplixCount+] | [{ph.ReplixCount}] | returns comment count |
| [+ReplixSubscribe+] | [{ph.ReplixSubscribe}] | returns 1 0 if disabled, 1 = subscribe (not subscribed), 2 = unsubscribe (is subscribed) |
| [+ReplixSubscribeLink+] | [{ph.ReplixSubscribeLink}] | contains the (un)subscribe link portion, must be used in combination with [~[*id*]~] |
example of the usage of subscription links in your document template:
<a href="[~[*id*]~][{ph.ReplixSubscribeLink;magnet=a}]" onclick="return confirm('Are you sure you wish to enable notification of new replies for this topic?');">[{onshow;block=a;when [{ph.ReplixSubscribe}]=1}]subscribe</a>
<a href="[~[*id*]~][{ph.ReplixSubscribeLink;magnet=a}]" onclick="return confirm('Are you sure you wish to disable notification of new replies for this topic?');">[{onshow;block=a;when [{ph.ReplixSubscribe}]=2}]unsubscribe</a>
if you use
&tagid the placeholder names get appended with the tagid. So if your
tagid = 1 the placeholder name for the comment count will be
[+ReplixCount1+] Templating: More documentation coming up. Take a look at the default templates in the replix directory to grasp the methods of working with TBS.
| replix.tag | |
| replix.link | |
| replix.moderate | |
| replix.guestname | |
| replix.guestform | |
| replix.captcha | |
| replix.cseed | |
| replix.error | |
| replix.nav.total | |
| replix.nav.start | |
| replix.nav.end | |
| replix.page.length | |
| replix.page.total | |
| replix.page.current | |
| replix.page.link | |
form.inc.htmlcomment.inc.htmlUsage examples: -
[[Replix? &captcha='1' &subscribe='true' &sortorder=`1` &makefolder=`1` ]]- Add
[[Replix? &mode=`comments.count` &docid=`*`]] to return number of comment from within any chunk or template.
Replace * with the docid of the target document (
NOT the docid of the actual xml document containing the comments)
ea. for a Ditto listing chunk you can add:
[[Replix? &mode=`comments.count` &docid=`[+id+]`]] to show the number of comments.
Examples using other snippets: - MaxiGallery (see
this post)
History: * June 18, 2006 -- version 1.7.0
- added: TBS template system
- added: pagination support (replaced &recentposts parameter)
- added: moderation automatically available for manager users.
- removed: all parameters involving display (use TBS template syntax instead, see default templates)
* June 1, 2006 -- version 1.6.0 beta
- changed: template include files
- added: guest form part template
- added: custom fields variables
- added: guest name variable (default: Anonymous)
* May 29, 2006 -- version 1.5.0 final
- changed: captcha variable and added functionality
- changed: template variables
- added: (un)subscribe template
- added: notify template
- small code cleanup
* May 24, 2006 -- version 1.5.0 beta
- added: captcha check (thx Garryn)
- added: subscriptions (subscriptions are only available to logged in users)
- added: moderation (delete only) by defined webuser groups
- removed: some style options (almost all can be done in chunk anyway)
- changed 'listcount' into 'comments.count'
- changed: default chunks
- rewrote a lot of routines and created a seperate class
* May 23, 2006 -- version 1.1.0
- added: listcount mode
- added: xpath class for comment handling
* May 22, 2006 -- initial release
Known issuesif you use a PHP5 setup and you get the following error:
Warning: Call-time pass-by-reference has been deprecated - argument passed by value;
If you would like to pass it by reference, modify the declaration of xml_set_object().
If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file.
However, future versions may not support this any longer.
in [MODX PATH]assets/snippets/replix/phpdomxml/lib.xml.inc.php on line 860
Do as the error advises and change the value in the INI file. Future updates of Replix will fix this issue by using the PHP5 XML functionality rather than the with replix included xml class.
more updates soon...
EDIT: changed "voor" to "for"