Fork me on GitHub
Current releases are 2.1.5 (31 Oct 2014) and 2.0.18.13 (5 Aug 2014)

Ready for 2.1? Find out if your plugins are compatible. 2.0 will no longer be updated after Dec 2014.

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

Tagged:

Best Answer

  • peregrineperegrine ☯ hasta luego :) In-Flight 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.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

    intothev01d

Answers

  • 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

    UnderDog
  • 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 ☯ hasta luego :) In-Flight 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 :)

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

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

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP

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

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

Sign In or Register to comment.