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.

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

edited April 2012 in Vanilla 2.0 - 2.8

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.

Tagged:

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 : '');
    

    to

    $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.

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

Answers

  • 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

    There was an error rendering this rich post.

  • 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 http://vanillaforums.org/addon/pagenavigator-plugin.

    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 :)

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

  • 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 ✭✭✭

    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.

    There was an error rendering this rich post.

  • 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 : '');
    

    to

    $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.

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

  • edited April 2012

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

    Side note: In 2.0.18.4 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.

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

Sign In or Register to comment.