Fork me on GitHub
Current release is 2.1.6 (21 Nov 2014).

Users who have not yet upgraded to 2.1 should get security release 2.0.18.14 (1 Nov 2014). We will stop providing these security releases to 2.0 at the end of this year.

Paging At The Top

VinVin
edited July 2011 in Vanilla 2.0 Help
Not sure how but would like to also have the paging on the top and not just the bottom for topic and discussion view. Any way to safely and quickly accomplish this?
Tagged:

Answers

  • So I am going to take this silence as an answer to hack the code?
  • edited July 2011
    In my dev theme, I've added an index.php to /views/discussions that looks like this:

    <?php if (!defined('APPLICATION')) exit();
    $Session = Gdn::Session();
    include($this->FetchViewLocation('helper_functions', 'discussions', 'vanilla'));


    if ($this->DiscussionData->NumRows() > 0 || (isset($this->AnnounceData) && is_object($this->AnnounceData) && $this->AnnounceData->NumRows() > 0)) {
    $PagerOptions = array('RecordCount' => $this->Data('CountDiscussions'));
    if ($this->Data('_PagerUrl')) {
    $PagerOptions['Url'] = $this->Data('_PagerUrl');
    }
    echo PagerModule::Write($PagerOptions);
    WriteFilterTabs($this);
    ?>
    <ul class="DataList Discussions">
    <?php include($this->FetchViewLocation('discussions')); ?>
    </ul>
    <?php
    $PagerOptions = array('RecordCount' => $this->Data('CountDiscussions'));
    if ($this->Data('_PagerUrl')) {
    $PagerOptions['Url'] = $this->Data('_PagerUrl');
    }
    echo PagerModule::Write($PagerOptions);
    } else {
    ?>
    <div class="Empty"><?php echo T('No discussions were found.'); ?></div>
    <?php
    }


    I *think* that's all I needed to do to do the trick, but I've stopped working with Vanilla2 until the plugins available (and the core code itself) stabilize some more, and it's been a while since I looked at it.
  • Working with the templates in Vanilla 2 is even more of a nightmare than it used to be, sadly.
  • Thanks for that stavthewonderchicken, works like a champ! Anyway to handle it in comments?
  • edited August 2011
    @Vin Here's my views/discussion/index.php -- if that last one worked, this probably should, too.


    <?php if (!defined('APPLICATION')) exit();
    $Session = Gdn::Session();
    $DiscussionName = Gdn_Format::Text($this->Discussion->Name);;
    if ($DiscussionName == '')
    $DiscussionName = T('Blank Discussion Topic');

    if (!function_exists('WriteComment'))
    include($this->FetchViewLocation('helper_functions', 'discussion'));

    if ($Session->IsValid()) {
    // Bookmark link
    echo Anchor(
    '<span>*</span>',
    '/vanilla/discussion/bookmark/'.$this->Discussion->DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($this->SelfUrl),
    'Bookmark' . ($this->Discussion->Bookmarked == '1' ? ' Bookmarked' : ''),
    array('title' => T($this->Discussion->Bookmarked == '1' ? 'Unbookmark' : 'Bookmark'))
    );
    }

    $PageClass = '';
    if($this->Pager->FirstPage())
    $PageClass = 'FirstPage';

    ?>
    <div class="Tabs HeadingTabs DiscussionTabs <?php echo $PageClass; ?>">
    <ul>
    <li><?php
    if (C('Vanilla.Categories.Use') == TRUE) {
    echo Anchor($this->Discussion->Category, 'categories/'.$this->Discussion->CategoryUrlCode);
    } else {
    echo Anchor(T('All Discussions'), 'discussions');
    }
    ?></li>
    </ul>
    <div class="SubTab"><?php echo $DiscussionName; ?></div>
    </div>
    <?php echo $this->Pager->ToString('more');?>
    <?php $this->FireEvent('BeforeDiscussion'); ?>
    <ul class="MessageList Discussion <?php echo $PageClass; ?>">
    <?php echo $this->FetchView('comments'); ?>
    </ul>
    <?php
    $this->FireEvent('AfterDiscussion');
    if($this->Pager->LastPage()) {
    $LastCommentID = $this->AddDefinition('LastCommentID');
    if(!$LastCommentID || $this->Data['Discussion']->LastCommentID > $LastCommentID)
    $this->AddDefinition('LastCommentID', (int)$this->Data['Discussion']->LastCommentID);
    $this->AddDefinition('Vanilla_Comments_AutoRefresh', Gdn::Config('Vanilla.Comments.AutoRefresh', 0));
    }

    echo $this->Pager->ToString('more');

    // Write out the comment form
    if ($this->Discussion->Closed == '1') {
    ?>
    <div class="Foot Closed">
    <div class="Note Closed"><?php echo T('This discussion has been closed.'); ?></div>
    <?php echo Anchor(T('&larr; All Discussions'), 'discussions', 'TabLink'); ?>
    </div>
    <?php
    } else if ($Session->IsValid() && $Session->CheckPermission('Vanilla.Comments.Add', TRUE, 'Category', $this->Discussion->PermissionCategoryID)) {
    echo $this->FetchView('comment', 'post');
    } else if ($Session->IsValid()) { ?>
    <div class="Foot Closed">
    <div class="Note Closed"><?php echo T('Commenting not allowed.'); ?></div>
    <?php echo Anchor(T('&larr; All Discussions'), 'discussions', 'TabLink'); ?>
    </div>
    <?php
    } else {
    ?>
    <div class="Foot">
    <?php
    echo Anchor(T('Add a Comment'), SignInUrl($this->SelfUrl.(strpos($this->SelfUrl, '?') ? '&' : '?').'post#Form_Body'), 'TabLink'.(SignInPopup() ? ' SignInPopup' : ''));
    ?>
    </div>
    <?php
    }


    <?php
    }
    </
  • That last little chunk of code is extraneous... can't figure out how to delete it. Ignore!
  • Thanks again! I put the new code in place and get a Bonk, tried to rework things a bit but still the bonk, any ideas why?
  • battersbatters New
    edited September 2011
    @stavthewonderchicken hi, you could help to make this paging before the discussions(or rather after the first post topic of author) I really need it, I tried both your code, but unfortunately they do not work.

    When I try to replace the contents of the file with your first code in index.php ( /views/discussions) then an error and the home page of site does not work Fatal error: Call to undefined method PagerModule::Write() in /public_html/applications/vanilla/views/discussions/index.php on line 11
    the other pages work without changes

    When I try to replace the contents of the file with your second code in index.php ( /views/discussion) that site is working partly; This means when you open the site as a guest (not registered), the site is down, and breaks the whole design (like on the picture)
    image
    But when you open the discussion as a registered user, then no error, the site is working and paging appears at the top before the first message of the author.

    You could fix this code, and preferably make the paging after the first message of the author(like on picture)?
    image

    i use 2.0.17.9 version
    plugins:
    AboutMe
    Anonymouse 2
    EasyReply
    Emotify :)
    Flagging
    Following
    Gravatar
    Magic
    Mark All Viewed
    Pockets
    Post Count
    Quotes
    RecentActivity
    RussianPlural
    Signatures
    Thankful People
    TopPosters
    Twitter
    User List
    Voting
    Web Title
  • SheilaSheila ✭✭
    edited June 2012

    Hi! Tested @stavthewonderchicken 's solution, was not able to get it to work. I'd like to add paging to top on discussion and a single discussion view. My vanilla version is 2.0.18.4.

    Anybody willing to help? This would increase usability.

  • SheilaSheila ✭✭

    Sorry for the bump, but I'm really looking to have this feature since I feel it is something that increases usability. I'm using slightly modified (mostly colours) default theme but I'm not just able to solve this by my self.

    Besides paging at the top I'd like to add 'Back to the top' link at the end of each single conversation thread.

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited June 2012

    Too tired to mess with a plugin but if you want to modify the index.php

    this would do it for the discussions view.

    vanilla/applications/vanilla/views/discussions/index.php

    <?php if (!defined('APPLICATION')) exit();
    $Session = Gdn::Session();
    include($this->FetchViewLocation('helper_functions', 'discussions', 'vanilla'));
    
    WriteFilterTabs($this);
    if ($this->DiscussionData->NumRows() > 0 || (isset($this->AnnounceData) && is_object($this->AnnounceData) && $this->AnnounceData->NumRows() > 0)) {
    
       $PagerOptions = array('RecordCount' => $this->Data('CountDiscussions'), 'CurrentRecords' => $this->Data('Discussions')->NumRows());
       if ($this->Data('_PagerUrl')) {
          $PagerOptions['Url'] = $this->Data('_PagerUrl');
       }
       echo PagerModule::Write($PagerOptions);
    
    ?>
    <ul class="DataList Discussions">
       <?php include($this->FetchViewLocation('discussions')); ?>
    </ul>
    <?php
     $PagerOptions = array('RecordCount' => $this->Data('CountDiscussions'), 'CurrentRecords' => $this->Data('Discussions')->NumRows());
       if ($this->Data('_PagerUrl')) {
          $PagerOptions['Url'] = $this->Data('_PagerUrl');
       }
       echo PagerModule::Write($PagerOptions);
    
    } else {
       ?>
       <div class="Empty"><?php echo T('No discussions were found.'); ?></div>
       <?php
    }
    

    Besides paging at the top I'd like to add 'Back to the top' link at the end of each single conversation thread.

    In answer to your Besides paging at the top I'd like to add 'Back to the top' link at the end of each single conversation thread. The pagenavigator plugin provide a top link, you could modify it to what you want to do.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

    Sheilakirkpa31
  • peregrineperegrine ☯ hasta luego :) In-Flight MVP
    edited June 2012

    for the discussion you could try changing adding echo $this->Pager->ToString('more');
    in /var/www/vanilla/applications/vanilla/views/discussion/index.php around line 15. e.g.

    if($this->Pager->FirstPage()) 
        $PageClass = 'FirstPage'; 
    echo $this->Pager->ToString('more');    
    

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

    SheilaAdrian
  • SheilaSheila ✭✭

    Great, thanks again :)

    Implemented both, and a bit weird since I see nothing new happening. It might be a good idea thou for me to give it another try tomorrow.

  • peregrineperegrine ☯ hasta luego :) In-Flight MVP

    just for laughs try using the default theme that came with vanilla. Then you can prove to yourself it works. It may be that your theme is overriding the default. In that case you need to add it to your theme views folder in the appropriate places.

    Monetary Donations will be appreciated if you use my plugins. Thanks in Advance.
    As a waiter gets a tip for a good meal, tips for successful solutions appreciated as well. Peregrine

    Sheila
  • SheilaSheila ✭✭

    Oh, yes, naturally. Made the changes again, but within theme folder. Feel like a total idiot now... :D

    No wonder I didn't see any changes previously. Works like a charm!

Sign In or Register to comment.