Dec 04, 2008, 12:29 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Read what MODx Developers say: MODx Dev. Blogs
Pages: [1] 2 3 ... 9   Go Down
  Print  
Author Topic: [Snippet] Replix 1.7.5 (upd 19-06)  (Read 34460 times)
0 Members and 1 Guest are viewing this topic.
bS
Coding Team
*
Posts: 398



WWW
« on: May 22, 2006, 09:59 AM »


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:

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

Code:
<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.html
comment.inc.html

Usage 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 issues

if you use a PHP5 setup and you get the following error:

Code:
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"

* Replix-1.7.5-Snippet.zip (73.46 KB - downloaded 549 times.)
« Last Edit: Oct 02, 2006, 02:03 PM by bS » Logged

Armand Pondman
MODx Coding Team
:: Jot :: PHx
rthrash
Foundation
*
Posts: 9,575



WWW
« Reply #1 on: May 22, 2006, 10:01 AM »

very cool... can't wait to see what all you add later... Smiley

How about allowing folks to subscribe to the comments via email?
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
bS
Coding Team
*
Posts: 398



WWW
« Reply #2 on: May 22, 2006, 10:36 AM »

How about allowing folks to subscribe to the comments via email?

coming up Wink
Logged

Armand Pondman
MODx Coding Team
:: Jot :: PHx
OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,054


looking a little more like my avatar again...


WWW
« Reply #3 on: May 22, 2006, 10:51 AM »

Great contribution Bs; been wanting exactly this for some time.  Cheers...
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
The spirit of a warrior is not geared to indulging and complaining, nor is it geared to winning or losing. The spirit of the warrior is geared only to struggle, and every struggle is a warrior's last battle on earth. Thus the outcome matters very little to him. In his last battle on earth a warrior lets his spirit flow free and clear. And as he wages his battle, knowing that his intent is impeccable, a warrior laughs and laughs.
  — don Juan Matus
bS
Coding Team
*
Posts: 398



WWW
« Reply #4 on: May 22, 2006, 11:16 AM »

only down side to this is I can't use xpath and xsl... there are classes out there that would do the trick but they just don't cut it. Or does someone here know a good class I can use?

I could use the XML DOM and XSL configure option but that's not a default setting on most shared hosting environments.
Logged

Armand Pondman
MODx Coding Team
:: Jot :: PHx
Mark
Coding Team
*
Posts: 3,247


Ditto Developer


WWW
« Reply #5 on: May 22, 2006, 03:58 PM »

This is SWEEEEEEEEEET! Great work!
Logged

The Man Can!
Testers
*
Posts: 296



WWW
« Reply #6 on: May 22, 2006, 07:12 PM »

This works beautifully! Thanks for the great addition. I just started using the UserComments last night (for the first time ever) and couldn't believe that it hardcoded the styles in. Less than 12 hours later, you post this beauty! Thanks.
Logged

Need MODx Ecommerce? Try FoxyCart!
OncleBen31
Sr. Member
****
Posts: 283


I believe in MODx!


WWW
« Reply #7 on: May 23, 2006, 05:37 AM »

Great snippet  Smiley, I will use it quickly !

Related topics :
  • Is there a snippet to count the number of comments posted  like UserCommentsCount ?
  • Is there an easy way to update it to work with SMF like SMF_UserComments ?
Logged
bS
Coding Team
*
Posts: 398



WWW
« Reply #8 on: May 23, 2006, 07:41 AM »

  • Is there a snippet to count the number of comments posted  like UserCommentsCount ?

use [+Replix.Count+] in your template or content page to show the number of posts

  • Is there an easy way to update it to work with SMF like SMF_UserComments ?

Yes there is.. but i'm using the SMF bridge plugin for that in future version.

Logged

Armand Pondman
MODx Coding Team
:: Jot :: PHx
OncleBen31
Sr. Member
****
Posts: 283


I believe in MODx!


WWW
« Reply #9 on: May 23, 2006, 08:06 AM »

use [+Replix.Count+] in your template or content page to show the number of posts
I know this but I think we need a specific snippet if we wanted to add the number of comments in the output of NewsListing or Ditto

Yes there is.. but i'm using the SMF bridge plugin for that in future version.
I've to test the SMF bridge more than I've done because I didn't find it very handy
Logged
rthrash
Foundation
*
Posts: 9,575



WWW
« Reply #10 on: May 23, 2006, 08:30 AM »

I'm a big fan purpose-specific snippets when possible. I'd love to see an external counting snippet for this code. Smiley
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
bS
Coding Team
*
Posts: 398



WWW
« Reply #11 on: May 23, 2006, 12:51 PM »

*bump*

I succesfully implemented the comment count request by using the same snippet.
I added a listcount mode so you can add the snippet into a chunk of Ditto/Newslisting or any other chunk.

version 1.1.0 and instructions have been added to my first post in this thread.
« Last Edit: May 23, 2006, 12:53 PM by bS » Logged

Armand Pondman
MODx Coding Team
:: Jot :: PHx
OncleBen31
Sr. Member
****
Posts: 283


I believe in MODx!


WWW
« Reply #12 on: May 23, 2006, 02:06 PM »

Waow ! Reponse and update in few hours  Kiss

Great, I think this snippet will be a must have like Ditto or DropMenu.
Logged
OncleBen31
Sr. Member
****
Posts: 283


I believe in MODx!


WWW
« Reply #13 on: May 23, 2006, 02:34 PM »

Can you just add the way to update from 1.0 to 1.1.0 ? I think it is not necessary to copy all the file.
Logged
bS
Coding Team
*
Posts: 398



WWW
« Reply #14 on: May 23, 2006, 04:59 PM »

all files changed except the phpdom class directory  Smiley
« Last Edit: May 23, 2006, 07:03 PM by bS » Logged

Armand Pondman
MODx Coding Team
:: Jot :: PHx
Pages: [1] 2 3 ... 9   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!