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.

I need a way for a redirection to the latest new comment by clicking '%number% new'*

edited April 2012 in Vanilla 2.0 - 2.8

after enter into the theme by click it is focused by the last comment and #Item signature is added to the url .

How to make the entering without focusing to last comment?


Best Answers


  • Answer ✓

    For that, open the /conf/config.php in your Vanilla forum directory, and add this line at the end of the file:

    $Configuration['Vanilla']['Comments']['AutoOffset'] = FALSE;
  • Thank you, badlearner :)

  • hbfhbf wiki guy? MVP
    Answer ✓

    It doesnt go to the last comment.... it goes to the last comment you read.

  • Well, I really need a way for a redirection to the latest new comment by clicking '%number% new' notification.

    How to do this?

  • edited April 2012

    New comments in discussion list (and (New comments in Bookmarked))



    1 $Configuration['Vanilla']['Comments']['AutoOffset'] = TRUE;

    further in file: forum\applications\vanilla\views\discussions\helper_functions.php
    function WriteDiscussion(

    2 change $DiscussionUrlNew = '/discussion/' setting to

    3 adding definition

    $DiscussionUrl = '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name);


    if ($Session->IsValid() && $Discussion->CountUnreadComments > 0) echo '<strong><a href="'.$DiscussionUrlNew.'">'.Plural($Discussion->CountUnreadComments, '%s New', '%s New Plural').'</a></strong>';


    in file: forum\applications\vanilla\controllers\class.discussioncontroller.php
    comment lines

             //if ($this->Discussion->CountCommentWatch > 0 && $OffsetProvided == '')
             //   $this->AddDefinition('LocationHash', '#Item_'.$this->Discussion->CountCommentWatch);


  • edited April 2012

    bugs, bugs...

    must be
    1 paragraph in previous scheme changed to false
    $Configuration['Vanilla']['Comments']['AutoOffset'] = FALSE;
    5 paragraph - uncomment .

    So 2-3 paragraphs make almost all right.
    in this case the posted comment is positioned on page.
    and a click on NEWS "tries" positioning on #Item
    and a click on the Discussion opens it from startpost


    UNproperly counting of news works now.

    I make a new post in Safari - Get @1 new@ notification in Opera.
    Click on @1 new@ - go to new post. then go to discussion list and get 15 new posts notification... ((((((

  • edited April 2012

    about 4 paragraph - making @Url-New@ for a link in the notification.

    in class.discussioncontroller.php the $offset are counted and $limit.
    then these variables are used in

    //Set the canonical url to have the proper page title.
          $this->CanonicalUrl(Url(ConcatSep('/', 'discussion/'.$this->Discussion->DiscussionID.'/'. Gdn_Format::Url($this->Discussion->Name), PageNumber($this->Offset, $Limit, TRUE)), TRUE));

    so in 4th paragraph the same urls with pages must be used ....

  • Futher investigations....

    in the Discussions List I set every discussion to be ended with "\p1" to show the first page by click. and latest comments ar shown by clicking the "new"-notification.

    Clicking the p1-ended-discussion erases off $CountCommentWatch to the start of second page .

  • forum\applications\vanilla\views\modules\discussion.php

       $url='/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 ? '/#Item_'.$Discussion->CountCommentWatch : '');
          echo Anchor(Gdn_Format::Text($Discussion->Name, FALSE), $url , 'DiscussionLink');
       <div class="Meta">
             echo '<span>'.$Discussion->CountComments.'</span>';
             if ($Discussion->CountUnreadComments > 0 || $Discussion->CountUnreadComments === '')
                echo '<strong><a href="'.$url.'">'.Plural($Discussion->CountUnreadComments, '%s new', '%s new').'</a></strong>';
Sign In or Register to comment.