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

    I’m currently using Jot so users can post about new events and its working okay. I’m wondering if its possible to be able to parse links or even use images in the comment section?

    For example if user posts a link in there comment it will become clickable. The other thing which would be perfect is to be able to post image link and it display on the page but if I could just get the links coming out as clickable links that would be great.

    Does anyone have any advice?

    I’m currently using

    [!Jot? &subscribe=`1` &placeholders=`1` &output='0' &canpost=`users` &canmoderate='modsgroup'!]
    
    [+jot.html.comments+]
    [+jot.html.navigation+]
    [+jot.html.form+]
    [+jot.html.moderate+]


    Thanks for your time
    • You can use bbcode with more extra features...
      See here: phx:bbcode
        God loves me. 【ツ】


        MODX.ir (Persian Support)

        Boplo.ir/modx/ (Persian)
        • 28849
        • 9 Posts
        An old topic, but no good answer - is there a way to unsert clickable links in comments?
          • 5532
          • 251 Posts
          I’m trying to accomplish the same thing with the last 5 comments in my sidebar. I found this forum topic about inserting a page title using Ditto here: http://modxcms.com/forums/index.php/topic,43850.0.html. But because of space restraints I’d rather have the comment clickable. Sorry, I didn’t understand the PHx bbcode suggestion above either.

          I’m using Evolution 1.0.2 with Jot 1.1.4

          For reference, here’s the Jot Call:
          <div class="widget">
          [[Jot? &docid=`*` &output=`0` &placeholders=`1` &moderated=`1` &pagination=`10` &css=`0` &badwords=`{{jotBadwordList}}` &bw=`1` &pagination=`3` &tplForm=`jotFormTpl` &tplComments=`last3CommentsTpl`]]
          <h3>Latest Comments:</h3>
          [+jot.html.comments+]
          </div>


          And here’s the Jot Template:
          <a name="jc[+jot.link.id+][+comment.id+]"></a>
          <div class="jot-row [+chunk.rowclass+] [+comment.published:is=`0`:then=`jot-row-up`+]">
          <div class="jot-comment">
          <div class="jot-content">
          
          <div class="jot-user">
          [+comment.createdby:isnt=`0`:then=``+][+comment.createdby:userinfo=`username`:ifempty=`[+comment.custom.name:ifempty=`[+jot.guestname+]`:esc+]`+][+comment.createdby:isnt=`0`:then=``+] SAYS:
          </div> 
          
          <div class="jot-message">
          [+comment.content:wordwrap:esc:nl2br+]
          </div>
          
          </div>
          </div>
          </div>


          Any suggestions would be welcome.

          Cheers
            • 5532
            • 251 Posts
            OK, changing the jot messgae div in the comment template to this:
            <div class="jot-message">
            <a href="[[Ditto? &documents=`[+comment.uparent+]` &tpl=`last3commentsLink`]]">[+comment.content:wordwrap:esc:nl2br+]</a>
            </div>
            


            Which references a separate Ditto chunk of:
            [+id+]


            Works for the first comment but the subsequent comments do not link to any page.

            If I substitute [+id+] for [+pagetitle+] in the Ditto template (and remove the link in the Jot template) I can see Ditto is outputting "No documents found" for all comments except the first one. Any ideas on how to get Ditto to find the doc ID of every comment?

            Cheers

              • 5532
              • 251 Posts
              Maybe this could have something to do with the hack outlined here which I performed to get Jot to recognise &docid=`*`
              http://modxcms.com/forums/index.php/topic,15746.msg108349.html#msg108349
                • 1122
                • 209 Posts
                @sunchez
                Without altering Jot’s core code, there is no way to insert clickable link directly into a comment. Jot behaves the following way: it takes the text of a comment, strips out any possible MODx tags, and for the remainder applies htmlspecialchars() function, so whatever we input into a comment field will be interpreted literally.

                @all
                The reason why Jot’s author implemented things in this way is obvious: inserting links by the site visitors (especially links to external images) is a straight way for ruining carefully designed layout. If you still want to do this, then you need to do this on your own thus taking full responsibility for a possible collapse of your layout.

                Suggestion by AHHP is neither old nor new, but it is a good solution -- one (if not only one) of the possible way how to activate static part of a comment within the very late phase of Jot’s processing. PHx (placeholders extended) is an opportunity to make alterations in a comment just in the moment when Jot finished doing its stuff, but the comment itself was not yet sent to the output. Maybe the way it should be used is unclear, so here are some explanations.

                PHx is a small snippet that you can use in a template and modify the value of a specific placeholder that PHx is applied to. As an example I am taking the template provided here by cms user:
                <div class="jot-message">
                [+comment.content:wordwrap:esc:nl2br+]
                </div>
                

                The above part of a template is responsible for displaying the body text of a comment. Placeholder [+comment.content+] already has three PHx applied: "wordwrap", "esc", and "nl2br". We want to activate links within this static body text and therefore we will apply fourth (custom) PHx:
                <div class="jot-message">
                [+comment.content:wordwrap:esc:nl2br:activatelinks+]
                </div>
                

                Now we need to define our custom PHx modifier "activatelinks". As it was mentioned before, PHx is an ordinary snippet, so we should define new snippet named (this is very important) "phx:activatelinks". As a snippet’s code I took -- adjusted to MODx environment -- functionality offered by "php:bbcode" and responsible for links:
                <?php
                /* phx:activatelinks */
                return preg_replace('#\(link=(.+?)\)(.+?)\(/link\)#is', '<a href="$1" target="_blank">$2</a>', $output);
                ?>
                

                Done. Now if someone inputs into the comment’s body a text like
                (link=http://setpro.pl/)Visit my site(/link)
                

                it will link to my homepage. Enjoy!
                  • 5532
                  • 251 Posts
                  Thanks for the reply, however I’m having trouble achieving two things:

                  1.
                  Displaying a list of the last 5 comments for the entire website in the sidebar.

                  2.
                  Having those comments displayed as links so a visitor can click the comment and be taken to the page/article displaying the comment.


                  The reason I posted in this thread was because I was able to modify the Ditto template suggested here to use the [+id+] placeholder and wrap it around each comment to create the link. Unfortunately I could only get Ditto to perform the operation to the first comment, leaving the others with no links.

                  With the first issue, I was able to display the last 5 comments for the entire site using the &docid=`*` hacks suggested in this thread:
                  http://modxcms.com/forums/index.php/topic,15746.msg108349.html#msg108349

                  But using &docid=`*` seem to stuff up the comment forms on the article pages so I’ve had to park this functionality until I can figure things out - in the mean time, although comments are displayed, posting and moderating no longer works even after a fresh download and install - I’m beginning to wonder if Jot is maybe incompatible with Evolution 1.0.2?


                  To my mind, there has to be a way of displaying the latest comments for a site and have them link back to their corresponding pages without hacking the Jot snippet or trying to combine two snippets - but as yet I can’t find any parameters or placeholders that will achieve this.

                  Any help or suggestions would be most welcome!

                    • 1122
                    • 209 Posts
                    I implemented a functionality described in your points 1. and 2. over two years ago -- you can see it here http://svoja.org/vitajemo.html&lang=EN (slightly scroll down and you should see "Latest Comments" section). Red link "»»" takes visitor to the comment section under the appropriate article while link "Publication » ..." takes user to the beginning of that article.

                    My impression from the time of this implementation is that Jot has no convenient and easy-to-understand way of doing this task. So I have solved this through the custom snippet. Scheme for such a snippet is:
                    <?php
                    /* scheme for LatestComments snippet */
                    
                    $count = 5; // how many latest comments
                    // fetch latest comments
                    $results = $modx->db->select('uparent,title,content,createdon', 'modx_jot_content', 'published=1', 'createdon DESC', $count);
                    // render output
                    $output = '';
                    while ($row = mysql_fetch_array($results, MYSQL_ASSOC)) {
                    
                      // now use $row['uparent'], $row['title'], $row['content'], $row['createdon']
                      // for building your list of latest comments
                      // $row['uparent'] -> id of the doc that the comment is attached to
                      // $row['title'] -> comment's title
                      // ...
                    
                      // for example, comment's title as a link to its article
                      $output .= '<div class="..."><a href="[~' . $row['uparent'] . '~]">' . $row['title'] . '</a></div>';
                    
                    }
                    return $output;
                    ?>
                    
                      • 5532
                      • 251 Posts
                      Thank you so much, I’ll investigate this further.

                      I’ve also just discovered through various forum posts (and trial and error) that my problems with Jot have been related to the fact that Jot 1.1.4 doesn’t seem to be compatible with PHx under Evolution 1.0.2

                      Do you know if this is correct? I’m using PHx to remove HTML if certain template variables are left empty so would like to keep it installed if possible.

                      Thanks again for your Snippet - much more than I expected!

                      Cheers

                      Ben