• Place the following after “your email” line in the b2commentspopup.php:
    <label for=”url”>Your URL:</label>
    <input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”28″ tabindex=”3″ />
    Click on a smilie to add it to your comment!
    <script language=”JavaScript” type=”text/javascript”>
    function emoticon(theSmilie) {
    theSmilie = ‘ ‘ + theSmilie + ‘ ‘;
    if (document.form.comment.createTextRange && document.form.comment.caretPos) {
    var caretPos = document.form.comment.caretPos;
    caretPos.text = caretPos.text.charAt(caretPos.text.length – 1) == ‘ ‘ ? theSmilie + ‘ ‘ : theSmilie;
    } else {
    document.form.comment.value += theSmilie;
    }
    document.form.comment.focus();
    theSmilie = ”;
    }
    </script>
    <?php
    $newrow = 0;
    $prev_val=””;
    asort($b2smiliestrans);
    while (list ($key, $val) = each ($b2smiliestrans)) {
    if($prev_val and $val==$prev_val) { }
    else if(!$prev_val or ($prev_val and $val!=$prev_val)){
    ?>
    <img src=”<?php echo “$smilies_directory/$val”; ?>” alt=”<?php echo $key; ?>” border=”0″ onclick=”emoticon(‘<?php echo $key; ?>’)” onmouseover=”style.cursor=’hand'” />
    <?php
    $newrow++;
    if($newrow == 14) { //new row after specified number of smilies
    echo ‘
    ‘;
    $newrow = 0;
    }
    }
    $prev_val = $val;
    }
    ?>
    <label for=”comment”>Your Comment:</label>
    <textarea name=”comment” id=”comment” cols=”40″ rows=”10″ tabindex=”4″>
    End before: <?php } else { // comments are closed ?>
    Sorry, comments are closed at this time.
    <?php }
    } // end password check
    ?>

Viewing 15 replies - 1 through 15 (of 67 total)
  • Hi,
    Think this would work on the main Post Entry page?

    I must be doing something wrong… when I click on a smilie, it tells me in the status bar that the page has errors and won’t add the smilie. I also have a script on there to automatically blod, italicize and link text in comments… is it possibly conflicting with that?

    Hmm, I tried this and keep getting an
    error on line 50
    character 1
    Error: ‘document.form.comment’ is null or not an object
    code: 0
    when i click on any of the smilies

    Ahhhh…. I forgot about Zone Alarm. I bet that’s my problem. Thanks! LOL

    Thread Starter southerngal

    (@southerngal)

    Welcome! ?? It’s one of the first things I check when something won’t load, like pop-ups! *LOL*

    Thread Starter southerngal

    (@southerngal)

    I have used my code on the pop-up comments with no problems and no modifications to the code. Others have asked me to put the code in their comments and it works for them as well.

    Sg, your code works wonderfully on the pop-up comments page. My modifications are designed for the main b2edit.php page, to enable smilies’ clickability in blog entries. ?? Sorry, didnt mean to say your code did not work.

    Thread Starter southerngal

    (@southerngal)

    ?? Mmmmmmkay! I will have to put that code in my entries page, thanks! I guess I just read it wrong…

    Southerngal, I tried using the code, but when the comments pop up, the text box shows the following inside it:
    End before:
    <div>Close this window.</div>
    <!– // this is just the end of the motor – don’t touch that line either ?? –>
    <p class=”credit”>0.030 <cite>Powered by WordPress</cite>
    <script type=”text/javascript”>
    document.onkeypress = function esc(e) {
    if(typeof(e) == “undefined”) { e=event; }
    if (e.keyCode == 27) { self.close(); }
    }
    </script>
    </body>
    </html>
    Is there some closing code missing so that it doesn’t put it all inside the text box? Also, the smilies won’t go in there while that code is there.
    Thanks.

    Southerngal, hold on, I’m getting some of it now. In your code above, the “end before” wasn’t part of the code, it was an instruction.
    However, even when I just replace the existing URL part with the code, I have to leave the submit button code that’s existing, otherwise they have no place to submit their comments.
    But when I try to replace the code now, I still get this code within the text box:
    <input name=”submit” type=”submit” tabindex=”5″ value=”Say it!” />
    </form>
    <div>Close this window.</div>
    <!– // this is just the end of the motor – don’t touch that line either ?? –>
    <p class=”credit”>0.026 <cite>Powered by WordPress</cite>
    <script type=”text/javascript”>
    document.onkeypress = function esc(e) {
    if(typeof(e) == “undefined”) { e=event; }
    if (e.keyCode == 27) { self.close(); }
    }
    </script>
    </body>
    </html>
    There’s gotta be something I’m missing that stops the coding and leaves the textbox working and the submit. Do you know what I’m doing wrong?

    Thread Starter southerngal

    (@southerngal)

    From the start body tag to the end body tag:
    <body>
    <?php /* this line is b2’s motor, do not delete it */
    $comments = $wpdb->get_results(“SELECT * FROM $tablecomments WHERE comment_post_ID = $id ORDER BY comment_date”);
    $commentstatus = $wpdb->get_row(“SELECT comment_status, post_password FROM $tableposts WHERE ID = $id”);
    if (!empty($commentstatus->post_password) && $HTTP_COOKIE_VARS[‘wp-postpass’] != $commentstatus->post_password) { // and it doesn’t match the cookie
    echo(“

    • “.get_the_password_form().”
    • “);
      }
      else {
      if ($comments) {
      // this line is WordPress’ motor, do not delete it.
      foreach ($comments as $comment) {
      ?>
      <!– comment –>
      <?php comment_text() ?>
      <?php comment_type(); ?> by <?php comment_author_link() ?> <?php comment_date() ?> @ “><?php comment_time() ?>
      <?php } // end for each comment
      } else { // this is displayed if there are no comments so far
      ?>
      No comments yet.
      <?php } ?>
      <b>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>” target=”_blank”>RSS feed for comments on this post.</b>
      <b>Trackback URL:
      <?php trackback_url() ?></b>
      <?php
      if (‘open’ == $commentstatus->comment_status) { ?>
      Line and paragraph breaks automatic. Just hit enter twice to place a break between paragraphs.
      <form action=”b2comments.post.php” method=”post” name=”form”>
      <label for=”author”>Your name:</label>
      <input type=”text” name=”author” id=”author” class=”textarea” value=”<?php echo $comment_author; ?>” size=”28″ tabindex=”1″ />
      <input type=”hidden” name=”comment_post_ID” value=”<?php echo $id; ?>” />
      <input type=”hidden” name=”redirect_to” value=”<?php echo htmlspecialchars($_SERVER[“REQUEST_URI”]); ?>” />
      <label for=”email”>Your email:</label>
      <input type=”text” name=”email” id=”email” value=”<?php echo $comment_author_email; ?>” size=”28″ tabindex=”2″ />
      <label for=”url”>Your URL:</label>
      <input type=”text” name=”url” id=”url” value=”<?php echo $comment_author_url; ?>” size=”28″ tabindex=”3″ />
      Click on a smilie to add it to your comment!
      <script language=”JavaScript” type=”text/javascript”>
      function emoticon(theSmilie) {
      theSmilie = ‘ ‘ + theSmilie + ‘ ‘;
      if (document.form.comment.createTextRange && document.form.comment.caretPos) {
      var caretPos = document.form.comment.caretPos;
      caretPos.text = caretPos.text.charAt(caretPos.text.length – 1) == ‘ ‘ ? theSmilie + ‘ ‘ : theSmilie;
      } else {
      document.form.comment.value += theSmilie;
      }
      document.form.comment.focus();
      theSmilie = ”;
      }
      </script>
      <?php
      $newrow = 0;
      $prev_val=””;
      asort($b2smiliestrans);
      while (list ($key, $val) = each ($b2smiliestrans)) {
      if($prev_val and $val==$prev_val) { }
      else if(!$prev_val or ($prev_val and $val!=$prev_val)){
      ?>
      <img src=”<?php echo “$smilies_directory/$val”; ?>” alt=”<?php echo $key; ?>” border=”0″ onclick=”emoticon(‘<?php echo $key; ?>’)” onmouseover=”style.cursor=’hand'” />
      <?php
      $newrow++;
      if($newrow == 14) { //new row after specified number of smilies
      echo ‘
      ‘;
      $newrow = 0;
      }
      }
      $prev_val = $val;
      }
      ?>
      <label for=”comment”>Your Comment:</label>
      <textarea name=”comment” id=”comment” cols=”40″ rows=”10″ tabindex=”4″></textarea>
      <input class=”button” type=”submit” value=”Say it!” />
      </form>
      <?php } else { // comments are closed ?>
      Sorry, comments are closed at this time.
      <?php }
      } // end password check
      ?>
      Close this window.
      <?php // if you delete this the sky will fall on your head
      }
      ?>
      <!– // this is just the end of the motor – don’t touch that line either ?? –>
      <?php //} ?>
      Powered by Word Press
      <?php
      // Seen at https://www.mijnkopthee.nl/log2/archive/2003/05/28/esc(18)
      ?>
      <script type=”text/javascript”>
      document.onkeypress = function esc(e) {
      if(typeof(e) == “undefined”) { e=event; }
      if (e.keyCode == 27) { self.close(); }
      }
      </script>
      </body>

    Thread Starter southerngal

    (@southerngal)

    Hopefully this will help you Jackie and anyone else hunting for the template. ??

    That worked perfectly, madame. Thank you so much ??
    I did buy a book on php and mysql. It’s fairly obvious I haven’t finished it but also that it’s not quite the book I need for this.

    I don’t understand how zone alarm has anything to do with it? Did I miss something because I’m getting the same error as the person with the…
    Error: ‘document.form.comment’ is null or not an object
    …yes, I have my smilies on and placed it where it should be.

    Is there a way to get the clickable smiles to work in the comments when not using the pop-up? I have my weblog set so that the comments load in the main window. I tried just using the bit of code that made the smiles and putting it into b2comments.php and the smiles show up but when clicked they don’t go into the comment field. I don’t get an error but nothing happens.

Viewing 15 replies - 1 through 15 (of 67 total)
  • The topic ‘Clickable Smilies in comments.’ is closed to new replies.