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.

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:


  • Options
    Is this more a theme related issue or is it vanilla? Does anyone know?
  • Options
    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
    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');
  • Options

    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 #.
  • Options
    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.
  • Options
    Good job @zhade I tested it and it works!! Hopefully @Mark and team will get this bug fixed.

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

    It looks like the issue is back in 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.