We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39131
    • 84 Posts
    Good morning,

    I'm using Articles (v.1.6.3) on MODX Revolution 2.2.6-pl.

    Everything is working fine so far.

    When a user fills in a comment on the blog an error appears, but the top of the page is shown and not the comment-field with the error.

    So the error is not visible for the user until he scrolls down again.

    Any tips how I can change that?

    Thanks in advance!


    Joost






      • 3749
      • 24,544 Posts
      Probably the best way would be to write JavaScript code to pop up an alert and put the focus on the problem field without submitting the form.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 39131
        • 84 Posts
        Hi Bob,

        thanks for your respons.

        At the moment my knowledge of JavaScript is however too limited to make this work.

        I was wondering if it is maybe possible to put something in the Articles code to change the behaviour in case a comment-field is not filled in.

        When the comment is succesfully sent, it shows just below the comment-fields.

        I prefer something like that. Just saw by accident that Mark Hamstra's blog is working that way.
          • 3749
          • 24,544 Posts
          I sent a Tweet to Mark. Hopefully, he'll chime in. wink
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
          • In your comment chunk (Article resource > Advanced > Display under Comments), make sure that your wrapper div (or in my case it's a list item), has an ID set like this:

            <li id="[[+idprefix]][[+id]]">


            That will give each comment an ID like qcom103, which can then be used as an anchor in the link. On my site I changed the idPrefix (not sure if Articles lets you change that) to "comments", so in my case the IDs are comments103 etc, but you can see that by appending #comments103 to the url, it immediately goes to the right comment: https://www.markhamstra.com/modx-blog/2013/02/extjs-dream-nightmare-jquery/#comments376

            When you have that ID set in your comment template it should work. The QuipReply snippet redirects the user back with the anchor in the link. (Make sure that if you changed the idPrefix like I did, that you also change it in the QuipReply snippet)
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 39131
              • 84 Posts
              Guys,

              thanks for the help!

              I'm gonna try to make it work.

                • 39131
                • 84 Posts
                Mark,

                I've tried several options, but none works.

                I can give each comment an ID, but that only shows after the comment is displayed.

                As far as I can see it is not generated when sending the form.

                The error besides the form is shown, but because by default the top op the page is shown, nobody will ever see that error-message (see attachment).

                Any further help is appreciated.

                Joost
                  • 39131
                  • 84 Posts
                  Eureka!

                  It's working now.

                  Only had to invest some extra hours smiley

                  • Can you share what did to resolve this? Right now none of my articles extra links work. I can only view the container summary page, the links to the actual articles or comments are not working.
                      • 39131
                      • 84 Posts
                      My comment chunk (Article resource > Advanced Settings > Display under Comments), is still set to quipComment.

                      In /core/components/quip/elements/chunks "quipcomment.chunk.tpl" is located.

                      I've changed this file a little:

                      <li class="comment" id="[[+idprefix]][[+id]]" [[+depth_margin:notempty=`style="padding-left: [[+depth_margin]]px"`]]>
                      <div id="[[+idprefix]][[+id]]-div" class="quip-comment-body [[+alt]]">
                      
                          <div class="avatar">
                              [[+gravatarUrl:notempty=`<img src="[[+gravatarUrl]]" class="quip-avatar" alt="" />`]]
                          </div>
                      
                          <div id="[[+idprefix]][[+id]]" class="comment-meta">
                              <p class="author">[[+authorName]]</p>
                              <p class="date">[[+createdon]]</p>
                              <span data-collapse>
                                  <p>Reageer</p>
                                  <div>[[!QuipReply? &thread=`[[+thread]]` &parent=`[[+id]]` &tplAddComment=`quipAddComment` ]]</div>
                              </span>
                      
                          </div><!-- END COMMENT-META-->
                      
                          <div class="comment-wrap">
                              <p>[[+body]]</p>
                          </div>
                      
                      </div>
                          [[+children:notempty=`<ul class="children">[[+children]]</ul>`]]
                      </li>


                      The first line is changed.