Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

PostNum with Link?

Is it possible to not only have the counter, but as well the appropriate link to the quote/contribution?

E.g. 'Post 3 of 14' as link so I could use this link as a reference to the comment. Would be helpful for cross-quoting, e.g. in other forums.

Tagged:

Comments

  • R_JR_J Ex-Fanboy Munich Admin

    Do you see the date/time beside of the avatar? That's a well hidden direct link to the comment.

  • hgtonighthgtonight ∞ · New Moderator

    As @R_J pointed out, the date is a permalink.

    However, I modded PostNum to be a link anyway. See the attached patch for details.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • hbfhbf wiki guy? MVP

    @hgtonight or anyone else - did this mod work for you? I'm getting a blank post URL based on the recommended code.

  • peregrineperegrine MVP
    edited November 2013

    didn't try it.

    but it looks like a relatively easy debug to see where it fails if at all.

    var_dump the $Object and see if it has Url in it.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hbfhbf wiki guy? MVP
    edited November 2013

    @peregrine said:
    didn't try it.

    but it looks like a relatively easy debug to see where it fails if at all.

    var_dump the $Object and see if it has Url in it.

    it doesn't, that's why i asked the question.

    the only way i found to accomplish this is to form the URLs myself. The comment object doesnt have a URL property - and $Object in this context isn't even the Comment, it's the Discussion. Bad use of naming, i know. I should be tarred and feathered.

    anyway here is the answer as long as you are using URL rewrites, if not then i dont know how to handle it.

    isset($Sender->EventArguments['Comment']) ?
    $postURL = "/discussion/comment/". $Sender->EventArguments['Comment']->CommentID . "#Comment_". $Sender->EventArguments['Comment']->CommentID:
    $postURL = "p1";

    this is brute force method. I don't like it.

  • hgtonighthgtonight ∞ · New Moderator

    Hmmm... I don't really remember writing this mod.

    It seems to always link to the discussion, not the comment.

    Any reason you are handling the Post Controller?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • peregrineperegrine MVP
    edited November 2013

    @hgtonight said:
    Hmmm... I don't really remember writing this mod.

    must have been on a binge night. no recall :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hbfhbf wiki guy? MVP

    @hgtonight said:
    Hmmm... I don't really remember writing this mod.

    It seems to always link to the discussion, not the comment.

    Any reason you are handling the Post Controller?

    'cause it's all about the Posts. Have to handle all controllers that are involved in the display of comments.

  • hbfhbf wiki guy? MVP

    BTW - my revised mod is live on my site. If someone can help me form the URLs properly under all conditions, I'll release an update.

  • here's a snippet of the way vanilla does it.

     $Type = property_exists($Object, 'CommentID') ? 'Comment' : 'Discussion';
    
    $Sender->EventArguments['Object'] = $Object;
    
    
     if ($Type == 'Comment') {
          $Sender->EventArguments['Comment'] = $Object;   
          $Id = 'Comment_'.$Object->CommentID;
          if ($Permalink === FALSE)
             $Permalink = '/discussion/comment/'.$Object->CommentID.'/#Comment_'.$Object->CommentID;
       } else {
          $Sender->EventArguments['Discussion'] = $Object;   
          $CssClass .= ' FirstComment';
          $Id = 'Discussion_'.$Object->DiscussionID;
          if ($Permalink === FALSE)
             $Permalink = '/discussion/'.$Object->DiscussionID.'/'.Gdn_Format::Url($Object->Name).'/p1';
       }
    
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hbfhbf wiki guy? MVP

    looks basically the same as my approach. good enough. i'll release it later today.

  • thats why I was wondering why you said brute force. seemed reasonable to me.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hbfhbf wiki guy? MVP

    @peregrine said:
    thats why I was wondering why you said brute force. seemed reasonable to me.

    it felt as i was writing it that there should be something, somewhere in the object model that provides the permalink url to whatever object you want to refer to. like a GDN_URLMONKEY($MySpecialObject) type method.

  • peregrineperegrine MVP
    edited November 2013

    gotcha hbf

    still wondering what the value of the mod is, i know someone wanted it, but there is a link or already in the date/time.

    or the op had something different in mind - that an autoquote is put in that you click on and it put a link in the new comment that says post 3 of 3

    because I don't see a whole lot of value to making post a clickable link other then for people who don't realize date/time is a permalink.

    It's always curious when the op never comes back to see comments on their post. granted this is many months old.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hbfhbf wiki guy? MVP

    value is low. very low. but hgtonight posted an answer so i thought i'd just put it into the plugin as a gesture of human kindness. then i found out it was wrong. so i got curious as to how best to solve this low value problem. so... here we are.

  • hgtonighthgtonight ∞ · New Moderator

    Thanks for catching my error!

    Like I said, I don't remember writing this at all.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight said:
    Thanks for catching my error!

    we've all seen the error in your ways :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hbfhbf wiki guy? MVP

    @hgtonight said:
    Thanks for catching my error!

    Like I said, I don't remember writing this at all.

    now you have to sit and wonder... "what else?"

Sign In or Register to comment.