We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31601
    • 57 Posts
    Right-o:

    Very annoying problem. I have had a problem where I use Ditto to call a series of documents, and I’m using a template to drive the output. The template then calls a chunk which uses Jot for comments.

    Here’s the Ditto call:

    [!Ditto? &tpl=`LatestNews` &display=`6` &parents=`75,40,41` &showPublishedOnly=`1` &hideFolders=`1` &depth=`2` &extenders=`summary` &truncLen=`800` &tplTrunc=`ReadMoreTpl`!]


    Here’s the template LatestNews:

     <div class="nl_summaryPost">
    <h2>[+longtitle+]</h2>
    [+summary+]
    <p style="clear:both"> </p>
    <p>[+link+]</p>
    {{BlogComments}}
    <div class="whereitis">published on: [+whereitis+]</div>
    </div>


    and here is the chunk BlogComments:

    <div id="ShowHideComments"><a class="togglecomments" href="javascript:;" onclick="new Effect.toggle('PostComment_[+id+]','blind');">Leave and read comments ([[Jot? &docid=`[+id+]` &action=`count-comments`]]) </a></div>
    <div id="PostComment_[+id+]" style="display:none">[[Jot? &docid=`[+id+]` &captcha=`1` &canmoderate=`Site Admins`]]</div>


    Now, as you can see, the Ditto call is called uncached, and the Chunk that calls Jot is cached. I’ve also tried this reversed, where I’ve made the ditto call cached and the jot call uncached, and I still have the same problem. The pages that are referred to in the Jot call are all set to be uncached. Of course, I have to do this or else I get code output instead of the proper Jot call, since it’s basically a snippet calling a snippet. I wish this would get fixed- but I know that this is a PHx issue.

    Anyways, what’s happening is every time I try and add a comment with Jot using captcha (which I have to do, because this site gets a ton of spam comment posts if I don’t!), I get that lovely error message "The security code you entered was incorrect." This happens in both IE7 and firefox.

    But what is REALLY weird- this doesn’t happen in Opera! It always posts the comment!

    I know I’m using scriptaculous, but I did some tests, removing the calls to scriptaculous in the template and removing it in the chunk shown above, and I STILL have the same problems. I even stripped out all javascript in a testing scenario from the template, and still have this problem!

    I just did an upgrade to 9601p2 to just see- that didn’t fix anything, and this same problem was there with Jot 1.1.2

    I’d love some insight as to what is going on here... help!
      • 1122
      • 209 Posts
      Please try to keep the Jot from output autorendering. Correct the call to the Jot in your BlogComments chunk with something like this...
      <div id="PostComment_[+id+]" style="display:none">
        [[Jot? &docid=`[+id+]` &captcha=`1` &canmoderate=`Site Admins` &output=`0` &placeholders=`1`]]
        [+jot.html.form+]
        [+jot.html.comments+]
        [+jot.html.navigation+]
        [+jot.html.subscribe+]
        [+jot.html.moderate+]
      </div>
      

      I feel it may solve the problem.
        • 31601
        • 57 Posts
        I’ve tried the snippet call for Jot as you recommended- I still have the same issue.

        What I don’t understand is why this seems to be a browser problem. As I stated in the original post, when I post comments using Opera, I don’t have this problem- only in IE7 and Firefox. Other users have reported the same problem.

        I’ve tried using meta tags to set the page to not be cached in the template for the page, but that didn’t seem to help, and I’ve tried cached/uncached settings for the document that calls the snippet with no change either.

        I must say it seems almost to be random- I can keep trying to post the same comment, entering the code each time, and once in a while (it seems to be random, I’ve tried it 6 times in a row), the comment will be succesfully published.

        I also pulled the database and installed 9.6.2 on my local machine, and I still have the same issue, so it doesn’t seem to be a server issue.

        Weirdness- seems to be a browser specific issue with how the captcha codes are generated in a multi-document call to Jot, because this issue doesn’t occur when comments are entered on the document when it’s viewed by itself, without using Ditto to get the document content.
          • 31601
          • 57 Posts
          Ok, an update-

          The security code message appears every other time after a round of 11 tests. 1st try=success, 2nd try=failure, 3rd try=success, 4th try=failure, and so on.

          Only in IE7 and Firefox- this issue doesn’t manifest itself in Opera.

          Also, I’ve inserted the header of my template:

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          
          <head>
          	<title>[(site_name)] | [*pagetitle*]</title>
                  <meta name="description" content="[*description*]"/>
                  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                  <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
                 <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
                 <META HTTP-EQUIV="Expires" CONTENT="0">
                  
          <link rel="stylesheet" href="[(base_url)]assets/templates/PorchTemplate2/styles.css" type="text/css" media="screen" />
          <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="[(site_url)][~11~]" />
                  <base href="[(site_url)]" />
          
          <!--[if lte IE 6]>
          
            <style type="text/css" media="screen, tv, projection">
                  body { behavior: url(assets/js/csshover.htc); } /* hover:anything support */ 
            </style>
          <![endif]-->
          <script type="text/javascript" src="assets/js/sleight.js"></script>
          <script src="assets/js/scriptaculous/prototype.js" type="text/javascript"></script>
          <script src="assets/js/scriptaculous/scriptaculous.js" type="text/javascript"></script>
          
          </head>
            • 31601
            • 57 Posts
            Aha- I think I see what is going on: The first documents that are retrieved by the Ditto call have the same Captcha image generated. I checked in the html source , and the random seed for the captcha image is the same for the first two items.

            so, I’m trying to see what is causing this? Any ideas???
              • 31601
              • 57 Posts
              Now it gets really interesting: Using placeholders instead of auto generated output by jot puts the same comment on all of the documents that have the same security code! AND I still can’t get validation in IE7 and Firefox.

              This is certainly VERY strange...
                • 1122
                • 209 Posts
                Hi, Virgil and all those who have experienced this problem. I think I have investigated why it occurs. The problem consists in that the captcha itself is designed to verify/validate single document while your application produces many documents on a single page. Each of these documents (outputted by Ditto call) tries to set its private verification code (captcha image produced by an each call to Jot). The veriword.php module, which handles the verification process, cannot validate the comment because it remembers only the one verification code -- this code is stored in a single variable $_SESSION[’veriword’]. During the verification process this variable is compared with the code inserted by user. The application produces many verification codes (as images) while the only one of it (probably the last generated) is actually remembered for the further comparison. To correct the situation you need to arrange a single verification code (for entire page) to be inserted for validation of any comment regardless of the document it is linked to. I hope I have clarified the issue.
                  • 31601
                  • 57 Posts
                  Alik-

                  Thank you for the insight into the functioning of the veriword module. You were absolutely right, and so I put together a solution that may work for others with this problem- I imagine it’s been done by others, but I think it would be of great benefit if the Jot wiki were updated with this issue, since I can imagine it crops up for people quite often!

                  I know this isn’t the most elegant solution, but I created a seperate call to Jot using a modified template for the form that only generates a captcha code for the page, and included this at the top of the page.

                  Here’s the modified template, which includes a few div wrapping elements so I could style it to display as I wanted:

                  <form method="post" action="[+form.action:esc+]#jf[+jot.link.id+]" class="captcha-display">
                  <div class="captcha-label">Please use the following security code when posting a comment:</div>
                  <div class="captcha-image">
                  [+jot.captcha:is=`1`:then=`
                  		<a href="[+jot.link.current:esc+]"><img src="[(base_url)]manager/includes/veriword.php?rand=[+jot.seed+]" width="148" height="60" alt="If you have trouble reading the code, click on the code itself to generate a new random code." style="border: 1px solid #003399" /></a>
                  </div>
                  <div style="clear:both"></div>
                  `:strip+]
                  </form>


                  Then, in the chunk that Ditto calls to bring up the jot comments for each article, I also modified a template for the form, stripping out the generation of each captcha code,yet leaves the field for entering the captcha code and the submit button. Here’s the modified template for the form for each article listing:

                  <a name="jf[+jot.link.id+]"></a>
                  <form method="post" action="[+form.action:esc+]#jf[+jot.link.id+]" class="jot-form">
                  	<fieldset>
                  	<input name="JotForm" type="hidden" value="[+jot.id+]" />
                  	<input name="JotNow" type="hidden" value="[+jot.seed+]" />
                  	<input name="parent" type="hidden" value="[+form.field.parent+]" />
                  	
                  	[+form.moderation:is=`1`:then=`
                  		<div class="jot-row">
                  			<b>Created on:</b> [+form.field.createdon:date=`%a %B %d, %Y at %H:%M`+]<br />
                  			<b>Created by:</b> [+form.field.createdby:userinfo=`username`:ifempty=`[+jot.guestname+]`+]<br />
                  			<b>IP address:</b> [+form.field.secip+]<br />
                  			<b>Published:</b> [+form.field.published:select=`0=No&1=Yes`+]<br />
                  			[+form.field.publishedon:gt=`0`:then=`
                  				<b>Published on:</b> [+form.field.publishedon:date=`%a %B %d, %Y at %H:%M`+]<br />
                  				<b>Published by:</b> [+form.field.publishedby:userinfo=`username`:ifempty=` - `+]<br />
                  			`+]
                  			[+form.field.editedon:gt=`0`:then=`
                  				<b>Edited on:</b> [+form.field.editedon:date=`%a %B %d, %Y at %H:%M`+]<br />
                  				<b>Edited by:</b> [+form.field.editedby:userinfo=`username`:ifempty=` -`+]<br />
                  			`+]
                  		</div>
                  	`:strip+]
                  	
                  	[+form.guest:is=`1`:then=`
                  		<label for="name">Name:<br />
                  		<input tabindex="[+jot.seed:math=`?+1`+]" name="name" type="text" size="40" value="[+form.field.custom.name:esc+]" />
                  		</label>
                  		<label for="email">Email:<br />
                  		<input tabindex="[+jot.seed:math=`?+2`+]" name="email" type="text" size="40" value="[+form.field.custom.email:esc+]" />
                  		</label>
                  	`:strip+]
                  	
                  	<label for="title">Subject:<br />
                  	<input tabindex="[+jot.seed:math=`?+3`+]" name="title" type="text" size="40" value="[+form.field.title:esc+]" />
                  	</label>
                  	<label for="content">Comment: *<br />
                  	<textarea tabindex="[+jot.seed:math=`?+4`+]" name="content" cols="50" rows="8">[+form.field.content:esc+]</textarea>
                  	</label><br />
                  	
                    [+jot.captcha:is=`1`:then=`
                  
                  		Security Code:<br /><input type="text" name="vericode" style="width:150px;" size="20" /> 
                  	`:strip+]
                  	
                  	<div style="float:right;width: 100px;"></div>
                  	<input tabindex="[+jot.seed:math=`?+5`+]" name="submit" type="submit" value="[+form.edit:is=`1`:then=`Save Comment`:else=`Post Comment`+]" />
                  	[+form.edit:is=`1`:then=`
                  		<input tabindex="[+jot.seed:math=`?+5`+]" name="submit" type="submit" value="Cancel" onclick="history.go(-1);return false;" />
                  	`+] 
                  	</fieldset>
                  </form>


                  So, you were absolutely right! I imagine there is a way to do this with let’s say an AJAX insert into each document call, but I didn’t want to go there right now, as I’m trying to manage so many things at once and learning constantly.

                  Gotta love ModX- so many ways to skin a cat, and this actually worked!

                  Thanks again, Alik! grin