HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Pager on profile tab doesn't work

Hey guys, I must be missing an obvious thing right here but I can't figure it out! I've played with it for a few hours and can't get it to work.

I'm trying to list all ratings that was given to a user, the initial data shows up fine, but when I click More Ratings it just doesn't do anything on page ( I see that it sends a request to p1/p2 etc and it's moving on but it doesn't load the received data)

I've used a snippet I saw around the forums to display the view and the pager I took from profile discussions. This is my source:

http://pastebin.com/WtAER7aG

Vanilla 2.1b2



Thanks in advance!

Comments

  • Do some decho() in your code, I don't think you're receiving the new $Page variable. It comes from your function call, but maybe it isn't sent somehow.

    There was an error rendering this rich post.

  • AviramAviram
    edited December 2013

    Hey UnderDog, thanks for the help, however I got this working by mimicking the Discussion's pager, but for some reason I can't get it to display other number of items per page, I can only display 30 results per page or it just screws up.. Here's my current source: http://pastebin.com/bSHweExF - What I've tried changing is:

    [code]

      $Sender->CountCommentsPerPage = 10;
    
      list($Offset, $Limit) = OffsetLimit($Page, 10);
    

    [/code]

  • Look at these 2 lines:

    $Sender->CountCommentsPerPage = C('Vanilla.Comments.PerPage', 30);
    
    list($Offset, $Limit) = OffsetLimit($Page, Gdn::Config('Vanilla.Discussions.PerPage', 30));
    

    Maybe there's something in there. But ... always decho() your values when things get screwy.

    There was an error rendering this rich post.

  • I tried, but I can't figure it out.. NVM that.. is there a way to add a link to the sidemenu?

  • I thought: "Maybe you can hook 'AfterAddSideMenu' for a custom link?" and then "Maybe that event has been mentioned at some time here in this forum"... BANG! http://vanillaforums.org/discussion/comment/152927#Comment_152927

  • R_JR_J Admin
    edited December 2013

    Oh, and here is an example on how I have implemented a pager somewhere else:

          // parse page offset
          $Offset = GetValue('0', $Sender->RequestArgs, '0');
          list($Offset, $Limit) = OffsetLimit($Offset, C('Plugins.YourPlugin.PostsPerPage', C('Vanilla.Discussions.PerPage', 30)));
          if (!is_numeric($Offset) || $Offset < 0) {
             $Offset = 0;
          }
    
    
          $PostsLimit = C('Plugins.YourPlugin.PostsLimit', 0);
          if ($PostsLimit > 0) {
             $Limit = min($Limit, $PostsLimit);
             $PostingsCount = count(YourPluginModel::Get(0,$PostsLimit));
          } else {
             $PostingsCount = count(YourPluginModel::Get());
          }      
    
            // Build a pager
          $Sender->SetData($PostingsCount);
            $PagerFactory = new Gdn_PagerFactory();
            $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
    
            $Sender->Pager->ClientID = 'Pager';
            $Sender->Pager->Configure(
                $Offset,
                $Limit,
                $PostingsCount,
                'YourPlugin/%1$s'
            );
    
          // Deliver JSON data if necessary
          if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) {
             $Sender->SetJson('LessRow', $Sender->Pager->ToString('less'));
             $Sender->SetJson('MoreRow', $Sender->Pager->ToString('more'));
             $Sender->View = 'YourPlugin';
          }
    

    But it was only copy & paste and try & error...

  • Awesome!

    But now I have a question... Where do you set these config settings?

    Plugins.YourPlugin.PostsPerPage
    Plugins.YourPlugin.PostsLimit
    

    Is it in the default.php of the plugin?

    Please sir... Step by Step please ...

    There was an error rendering this rich post.

  • AAAAAAH! Don't do that to me: I think I have a hereditary debility when it comes to irony!
    I was halfway ready with my answer when I started to hesitate and I'm still! unsure...

  • How can I copy / Paste that into my PHP file? Can @vrijvlinder make an icon in the meantime? (heheh, oil, fire, throw, repeat)

    There was an error rendering this rich post.

  • You have to create a custom theme for that ;)

  • UnderDogUnderDog MVP
    edited December 2013

    Please sir, Step by Step, please! Do I rename 'default' theme and leave it at that? Then change the style.css in the Vanilla Application? I don't know how to search sir! (Oh shit, we're in the Developers section, I have to stop joking after this one ... )

    There was an error rendering this rich post.

  • I think @aviram is going to create and add a nice add-on to the plugin section once its completed. That said, a bit more searching by Aviram and a bit more looking at other plugins that do similar things might be helpful to him.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • AviramAviram
    edited December 2013

    @peregrine , sorry I was misunderstood - I did search a lot and I did pretty same implemntation as @R_J gave me and it didn't work out, that's why I posted it here.

    Furthermore, I found the sidemenu solution for profile, but I want to add a link to the sidemenu that goes on the left when you're in discussions, and I think that I solved it by using eventi and understanding there's no easy solution as sidemenu->addlink that profile has, but I guess I'll just hook to AfterRenderAsset and try to add HTML code that would look native to the links layout.

    Sorry if it seems like I've been lazy on searching, I really did :)

    And of course when the addon will be "cooked" enough I'll release it, but that'd require a lot of beautifying as some of it was written in a hassle without fully understanding Vanilla's powers.
    Thanks guys.

  • Keep on asking: each answer I give helps me understanding better what I do here ;)

  • @R_J said:
    Keep on asking: each answer I give helps me understanding better what I do here ;)

    agreed. good questions and good answers as well.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.