We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4195
    • 398 Posts

    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:

    [table]
    [tr][td]Standard[/td][td]TBS Plugin equivalent[/td][td][/td][/tr]
    [tr][td][+ReplixForm+][/td][td][{ph.ReplixForm}][/td][td](if freeform is enabled)[/td][/tr]
    [tr][td][+ReplixCount+][/td][td][{ph.ReplixCount}][/td][td]returns comment count[/td][/tr]
    [tr][td][+ReplixSubscribe+][/td][td][{ph.ReplixSubscribe}][/td][td]returns 1 0 if disabled, 1 = subscribe (not subscribed), 2 = unsubscribe (is subscribed)[/td][/tr]
    [tr][td][+ReplixSubscribeLink+][/td][td][{ph.ReplixSubscribeLink}][/td][td]contains the (un)subscribe link portion, must be used in combination with [~[*id*]~][/td][/tr]
    [/table]

    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.

    [table]
    [tr][td]replix.tag[/td][td][/td][/tr]
    [tr][td]replix.link[/td][td][/td][/tr]
    [tr][td]replix.moderate[/td][td][/td][/tr]
    [tr][td]replix.guestname[/td][td][/td][/tr]
    [tr][td]replix.guestform[/td][td][/td][/tr]
    [tr][td]replix.captcha[/td][td][/td][/tr]
    [tr][td]replix.cseed[/td][td][/td][/tr]
    [tr][td]replix.error[/td][td][/td][/tr]
    [tr][td]replix.nav.total[/td][td][/td][/tr]
    [tr][td]replix.nav.start[/td][td][/td][/tr]
    [tr][td]replix.nav.end[/td][td][/td][/tr]
    [tr][td]replix.page.length[/td][td][/td][/tr]
    [tr][td]replix.page.total[/td][td][/td][/tr]
    [tr][td]replix.page.current[/td][td][/td][/tr]
    [tr][td]replix.page.link[/td][td][/td][/tr]
    [/table]

    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:

    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"
      Armand Pondman
      MODx Coding Team
      :: Jot :: PHx
      • 25663 MODX Staff
      • 12,272 Posts
      very cool... can’t wait to see what all you add later... smiley

      How about allowing folks to subscribe to the comments via email?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 4195
        • 398 Posts
        Quote from: rthrash at May 22, 2006, 10:01 AM

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

        coming up wink
          Armand Pondman
          MODx Coding Team
          :: Jot :: PHx
          • 22303 MODX Staff
          • 10,725 Posts
          Great contribution Bs; been wanting exactly this for some time. Cheers...
            • 4195
            • 398 Posts
            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.
              Armand Pondman
              MODx Coding Team
              :: Jot :: PHx
              • 18397
              • 3,250 Posts
              This is SWEEEEEEEEEET! Great work!
                • 29635
                • 361 Posts
                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.
                  Need MODx Ecommerce? Try FoxyCart!
                  • 22221
                  • 283 Posts
                  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 ?
                    • 4195
                    • 398 Posts
                    Quote from: OncleBen31 at May 23, 2006, 05:37 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

                    Quote from: OncleBen31 at May 23, 2006, 05:37 AM

                    • 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.

                      Armand Pondman
                      MODx Coding Team
                      :: Jot :: PHx
                      • 22221
                      • 283 Posts
                      Quote from: bS at May 23, 2006, 07:41 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

                      Quote from: bS at May 23, 2006, 07:41 AM

                      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