Fork me on GitHub
Please upgrade to 2.1.x here. The 2.0 branch is no longer being updated.
Critical: Update to 2.1.8, released 15 Jan.

[Solved][Documentation] link of a discussion title and page orientation

edited April 2012 in Vanilla 2.0 Help

I've noticed that when I click a the link of a discussion title, it takes me to the discussion page but always lands me at or near the bottom and I have to scroll back up. Is there any way to automatically insure I land at the top of a discussion page when the link is clicked as opposed to having to scroll up? If so what file and/or function do you need to edit to do this? Thanks.


Best Answer

  • peregrineperegrine MVP
    edited April 2012 Answer ✓

    If you don't want to give the users an option to go to the first comment as well as the first unread comment that the plugin provides you could modify code here:

    you could change line 13 in helper_functions.php in the directory aery mentioned.

      $DiscussionUrl = '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') && $Session->UserID > 0 ? '/#Item_'.$Discussion->CountCommentWatch : '');


    $DiscussionUrl = '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') && $Session->UserID > 0 ? '/#Item_'. '1' : '');

    it will go to the first item in discussion if you want.



  • 422422 Developer MVP

    If you look at the url, it is appended with hash id.

    This should take you to last unread comment. Its a feature not a flaw

    422 Real Estate Australia , now open Check it out

  • Ok. Yea I'm not saying its a bad thing or a bug I just wanted to know if it can be changed. For my implementation I would rather have people directed only to the top of the page and not the comments. Is there a file that adds the url hash id? If so where can I remove it to only show the page and not anchor to the newest comment?

  • peregrineperegrine MVP
    edited April 2012

    This following plugin allows you to leave the standard navigation from the title link and add optional links. e.g. you could add the plugin and enable first. That will give you the option to go to the first link or the unread link.

    You could look at

    or you could get an idea how to modify what you want with the title link.

    alternatively if you modify the code where the discussion link sets the title you could append to the end of the link with a bit of a kludge. '/x/p1'

    it will effectivly disable the hash addition and go to the first page of the discussion

    you could click the like button if it works for you :)

  • Well thanks for the suggestion. I tried the plugin but its simply placing additional links on the discussions and categories to go to the first post, not changing the title link to reference the top of the page. I'm not sure what file holds this information. Vanilla is quite a large set of files and I don't know which one I would even begin to look at to find where I can modify the discussion link. I'll start browsing through them but in the mean time I'm open to any other suggestions or if anyone knows what file I need. Thanks.

  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    You will need to manually edit link for the discussion page from applications>dashboard>views>dicussions . Remove the hash and I think that will do.

    Vanilla is sweet & support is great, to encourage volunteers, please donate.

  • edited April 2012

    Sorry for the late response here but your method works perfectly peregrine. Thanks a lot!

    Side note: In the helper_functions.php is located in applications>vanilla>views>discussions. Minor detail there but good for future reference. Thanks again to everyone who helped out!

  • thanks for the feedback. helps give other people confidence in a solution.

Sign In or Register to comment.