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.

HotThreads page navigation not working

Hi..

setup HotThreads plugin..

Vanilla=Version 2.0.18.11
HotThreads=Version' => '14.01.24'

Everything ok expect HotThreads page navigation..It's not showing any page navigation bottom of the hotthreads discussions page..

any help

Comments

  • businessdadbusinessdad Stealth contributor MVP

    Most probably, you don't have enough "hot discussions" to fill more than one page. If you want to check how many discussions are fetched, you can have a look at the HotThreadsPlugin::ShowHotThreads() method. From the code documentation for such method:

    Renders the Hot Threads page.
    This method is an almost exact copy of DiscussionController::Index(), with the exception that it doesn't load Announcements. Also, it loads only Discussions with a certain amount of Views or Comments

  • edited August 2014

    @businessdad said:
    Most probably, you don't have enough "hot discussions" to fill more than one page. If you want to check how many discussions are fetched, you can have a look at the HotThreadsPlugin::ShowHotThreads() method. From the code documentation for such method:

    i could confirm it has enough hot thread to display.because when i change following code it's give me navigation menu(but load same page result on every page navigation pages)

    change code

    $Sender->DiscussionData = $DiscussionModel->Get($Page, $Limit);

    to

    $Sender->DiscussionData = $DiscussionModel->Get($Page, 100);

    i check another site that using hot thread plugin..That site also has same problem..(loading first page result on every page navigation pages)

    @businessdad said:
    This method is an almost exact copy of DiscussionController::Index(), with the exception that it doesn't load Announcements. Also, it loads only Discussions with a certain amount of Views or Comments

    didn't know about it..i will check both php files..

  • edited August 2014

    for some reason your code Offset will not increment when go to second page..may be Offset mix with limit values.

    DiscussionController using below equation to calculate

    Offset = floor($CountCommentWatch / $Limit) * $Limit;

    but i didn't see such a calculation on your code... haven't code for use $CountDiscussions to calculate Offset value :\

    could u kindly check again using u test development site :D

  • businessdadbusinessdad Stealth contributor MVP
    edited August 2014

    @VanillaFan I will take note of this and have a look at it, but I can't say when, as I'm working on different projects at the moment (I look after the free plugins on this site on a "spare time" basis, and I have no spare time these days).

    Please note that the code you looked at does calculate the offset, it just calls it $Page. First line of HotThreadsPlugin::ShowHotThreads():

    // Determine offset from $Page
    list($Page, $Limit) = OffsetLimit($Page, C('Vanilla.Discussions.PerPage', 30));
    

    Note: if anyone is willing to contribute to the plugin development, the Github repository is https://github.com/daigo75/vanilla-hotthreads (there's a link also on the plugin page).

  • edited August 2014

    @businessdad said:
    This method is an almost exact copy of DiscussionController::Index(), with the exception that it doesn't load Announcements. Also, it loads only Discussions with a certain amount of Views or Comments

    wrong,after spend several hours i discovered it was DiscussionsController::Index() :D

    able to identify reason for not showing page numbers..It was Wrong Discussion Count

      // Get Discussion Count
        $CountDiscussions = $Sender->DiscussionData->NumRows();
        $Sender->SetData('CountDiscussions', $CountDiscussions);
    

    Need to get Discussion Count before below code

    $this->DiscussionData = $DiscussionModel->Get($Page, $Limit);

    current code Discussion Count will be generate using above result,that should be wrong..(it always give limit result as total count :( )

    To test set $CountDiscussions to fix value and page navigation numbers back :)

    $this->SetData('CountDiscussions', 50);
    

    But all pages loading same first results :'(

    So i guess their has another bug combined with Offset..

    I try to fix those bugs..but unable to do that :(

    if someone going fix those bugs hope this tip will be help

    Tip:-

    use following sql code to get total hot discussions

         SELECT COUNT(`DiscussionID`) FROM `Discussion` 
         WHERE CountViews >= 100 OR CountComments >=10;
    

    assign ablove total count to

      $this->SetData('CountDiscussions', $CountDiscussions);
    
  • businessdadbusinessdad Stealth contributor MVP

    @VanillaFan said:
    wrong,after spend several hours i discovered it was DiscussionsController::Index() :D

    Well spotted. A small "s" makes a big difference. This is the reason why I tend to avoid variables, classes and methods with similar names (singular/plural), I confuse them way too often.

    Regarding the pager, I was actually tempted to remove it altogether and put a cap to the amount of retrieved discussions. The purpose of the Hot Threads plugin is to display the "top X hot discussions", but not the "top 150.000 hot discussions". Having too many in the list would defeat the purpose of the plugin, as one could simply go to one of the many discussions lists to see them all, if needed.

  • businessdadbusinessdad Stealth contributor MVP

    Uploaded a fix for the bug. I don't have time to test it properly, so be careful.

  • edited August 2014

    Now page navigation back :D Thank you very much..even if u are busy, u help me,i appreciate your help o:)

    So i guess their has another bug combined with Offset..

    as i previously mention their has another bug...Even if u click second page it's load first page result..i try to debug and here what i found ;)

    debug code for first page

    debug code for second page

    For work as excepted page navigation and result

    First page code should be

    DiscussionModel->Get(0, '30')
    // some codes here
    limit 30;
    

    Second page code should be

    DiscussionModel->Get(30, '30')
    // some codes here
    limit 30, 30;
    

    As above images,Get method first parameter not increment when visit second page..

    hope this explain will help others to identify above problem.. when u have free time ,u could get some fun fixing bugs :D

  • edited September 2014

    Hurreyyyyyyyyyyyyy

    Able to identify problem and fix it ;)

    Remove code

       public function DiscussionsController_HotThreads_Create($Sender) {
            // Replace standard View with the "Hot Threads" view
            $this->ShowHotThreads($Sender, GetValue(0, $Args, 'p1'));
        }
    

    Change following Code

         private function ShowHotThreads($Sender, $Page = '0') {
    

    to

         public function DiscussionsController_HotThreads_Create($Sender, $Args) {
    
            $Page = ArrayValue(0, $Args, 0);
    
  • R_JR_J Ex-Fanboy Munich Admin

    How about adding $Args to the arguments?

    Before:

    public function DiscussionsController_HotThreads_Create($Sender) {
        // Replace standard View with the "Hot Threads" view
        $this->ShowHotThreads($Sender, GetValue(0, $Args, 'p1'));
    }
    

    After:

    public function DiscussionsController_HotThreads_Create($Sender, $Args) {
        // Replace standard View with the "Hot Threads" view
        $this->ShowHotThreads($Sender, GetValue(0, $Args, 'p1'));
    }
    
  • @R_J said:
    How about adding $Args to the arguments?

    Before:

    public function DiscussionsController_HotThreads_Create($Sender) {
        // Replace standard View with the "Hot Threads" view
        $this->ShowHotThreads($Sender, GetValue(0, $Args, 'p1'));
    }
    

    After:

    public function DiscussionsController_HotThreads_Create($Sender, $Args) {
        // Replace standard View with the "Hot Threads" view
        $this->ShowHotThreads($Sender, GetValue(0, $Args, 'p1'));
    }
    

    wow,That solutions better than my solution ;) Thank you very much :D

  • R_JR_J Ex-Fanboy Munich Admin

    Not sure, but I think Netbeans would have pointed out that the function is using an undeclared variable and thus made it quite easy to find the solution. Those are the benefits of a full blown IDE

  • businessdadbusinessdad Stealth contributor MVP

    @R_J said:
    Not sure, but I think Netbeans would have pointed out that the function is using an undeclared variable and thus made it quite easy to find the solution. Those are the benefits of a full blown IDE

    I actually do use a full blown IDE, but it doesn't report this kind of things. Not a big fan of Netbeans, though.

Sign In or Register to comment.