Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Linking directly to a comment

edited July 2006 in Vanilla 1.0 Help
Hi, I'm sure this has been covered, or that I am being a drongo, but I could find nothing in the doc/forums. I am uncertain how to link to directly to a comment in a discussion. I know Vanilla supports direct linking to the most recent comment, and you can use #item_x to link to a comment...but I am not sure how to access the actual #item_x URL. Any ideas?
«1

Comments

  • Actually there is no way, except by writing the proper extension. I had the same idea and planned to do this, but I don't know when. :)
  • MarkMark Vanilla Staff
    Well, if you know the text of a comment, you can search for it (use quotes around long sentences) and once you find it in the comment search results, right click the comment text and get the link from there. There is no way to get it directly from the comment without a helper extension. But that would be a pretty easy one to write.
  • Ok, here is the Comments Permalinks extension. I hope that's what you were looking for. :)
  • MarkMark Vanilla Staff
    Nice work, remouk.

    For the record, I took a look at it and saw that you had to resort to using a global variable. So, I added the $RowNumber to the delegate parameters collection in subversion. When the next revision comes out you'll be able to remove that global and just rely on the parameter.
  • You all are way too fast at writing extensions.
    Or else, Vanilla framework is just waaaaayyy easy to understand.
  • MarkMark Vanilla Staff
    edited July 2006
    I made the quick little change so that it doesn't use the global, svn updated this forum, and added the new version of it onto here. thanks, remouk!

    For the record, here is what I changed the source of the extension to here on lussumo.com/community:

    <?php /* Extension Name: Comments Permalinks Extension Url: http://lussumo.com/docs/ Description: Adds a "permalink" link to every comment, so you can share a single comment's url. Version: 1.0 Author: Remi Cieplicki Author Url: http://remouk.alt-tab.org/ You should cut & paste this language definition into your conf/your_language.php file (replace "your_language" with your chosen language, of course): */ $Context->Dictionary['Permalink'] = 'permalink'; function CommentGrid_Permalinks(&$CommentGrid) { $RowNumber = $CommentGrid->DelegateParameters['RowNumber']; $CommentList = &$CommentGrid->DelegateParameters["CommentList"]; $CommentList .= '<a href="#Item_'. $RowNumber .'" id="Permalink_'. $RowNumber .'">' . $CommentGrid->Context->GetDefinition("Permalink").'</a>'; } $Context->AddToDelegate("CommentGrid", "PostCommentOptionsRender", "CommentGrid_Permalinks"); ?>
  • wouldn't this be possible in the template system?
  • MarkMark Vanilla Staff
    Of course it would - but this way you don't have to create a whole new theme that you then have to maintain.
  • I meant your default template. like make the user icon, the permalink to the file perhaps.
  • Man... it just feels good to watch this stuff unfold! Hopefully I'll have time to contribute soon. Great job guys, and as always, Mark, you're the best!
  • That's really fantastic guys, thanks. To have the solution turned around in one day is remarkable.
  • Really cool Mark, I'll update it. :) I have a question: naming my extension comments_permalink (as asked here), contrary to CommentsPermalinks (like most of the other ones) make it appear on the bottom of the extension settings. It doesn't respect alphabetical sort anymore. Shall we rename my extension, and modify the instructions?

    P.S. Whispers must not have their own permalinks, I'll handle that (hopefully tomorrow).
  • Where does it say you have to call it comments_permalink instead of CommentsPermalinks? I think the "Name your add-on file like so: add_on_name.zip" just means your add-on archive should have the same name as the extension. All other extensions are using WikiWord like names.
  • MarkMark Vanilla Staff
    remouk - yeah, I renamed my copy to CommentPermalink so it would sort in the list properly. And good point about the whispers. I didn't think of that...
  • remoukremouk New
    edited July 2006
    Mark, to handle that properly, I think the best solution is to use the CommentId instead of that irrelevant ItemNumber. I want to had that: $Comment = $CommentGrid->DelegateParameters["Comment"]; in order to use $Comment->CommentID in my permalink. And for the permalink to work, I'll have to had another anchor, something like [a name="Comment_31265"][/a] (in html of course), but that's not really clean, having two anchors for the same place... What do you think about this?

    Additionnal question: why is Vanilla using Item_id instead of the real Comment_id (which cannot change, even if there are whispers or hidden comments)?
  • MarkMark Vanilla Staff
    That's a good question. I think I might just change that...
  • edited July 2006
    "P.S. Whispers must not have their own permalinks, I'll handle that (hopefully tomorrow)." - remouk

    Hey remouk,
    why not allow permalinks on whispers?

    (btw the new look of the preview post is awesome)
  • MarkMark Vanilla Staff
    Well, if I change the anchor to be the id of the comment instead of the number of the comment, then it will work.
  • That should also make a few other things easier, I would imagine.
  • just a suggestion, since you have the forum going with the XHTML standards, you can always use the anchor thats associated with the ids on the list tags.. so instead of using <a name="Comment_33236"></a> you can just have it link to that comments id..

    example
This discussion has been closed.