Please upgrade here. These earlier versions are no longer being updated and have security issues.

Remove Item # From URL

edited January 2011 in Vanilla 2.0 - 2.8
On the vanilla forums, I do not notice the Item_# showing at the end of the post URL. Where is that option located? I'm testing on vanilla2.0.16 and want to turn it off.

For example: http://www.example.com/vanilla/discussion/12/this-is-a-test/#Item_2

Comments

  • Is this more a theme related issue or is it vanilla? Does anyone know?
  • This appears when you have already visited the discussion before and therefore jumps to the post you have last read. With that you can continue reading the new posts right away without navigating to it manually.

    If you still want it removed, go to either
    \applications\vanilla\views\discussions\helper_functions.php
    or if you have a custom theme:
    \themes\<your theme>\views\discussions\helper_functions.php.

    Search for:
    echo Anchor($DiscussionName, '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_'.$Discussion->CountCommentWatch : ''), 'Title');
    and replace it with:
    echo Anchor($DiscussionName, '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name), 'Title');
  • @zhade

    Thank you for your response. I do not want it removed completely but do want it to work the right way. Shouldn't item # be added to links for logged in user only? I open in chrome, clear cache/cookies and then visit the test site. The item # shows up for regular posts. Announcements do not have the item #.
  • Ah, alright. After some searching I also found out why and when it happens.
    It is being added when your last visit in that discussion is later than the last post was made.
    You have two options: Either you edit the file where the time check is being made, or you simply add another condition on the helper_functions.php file.
    I would suggest later option, since it is theme orientated and you don't have to mess with the source code.

    Just go to the helper_function.php and on the same line I posted above you add after the C('Vanilla.Comments.AutoOffset'), the code
    && $Session->UserID > 0.

    So in the end it would be:
    echo Anchor($DiscussionName, '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') && $Session->UserID > 0 ? '/#Item_'.$Discussion->CountCommentWatch : ''), 'Title');
    If you want to know where the last visit check is being made, it is here:
    \applications\vanilla\models\class.discussionmodel.php line 222 & line 223,
    Just comment out those lines and you have the same effect.
  • Good job @zhade I tested it and it works!! Hopefully @Mark and team will get this bug fixed.

    Thank you!!
  • edited January 2011
    @Mark @zhade

    It looks like the issue is back in 2.0.17.3 and seem random. Some have Item # and some don't. Shouldn't "Mark All Viewed" take care of this?
Sign In or Register to comment.