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.
Paging At The Top
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:
0
Answers
<?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.
<?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('← 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('← 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
}
</
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)
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)?
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
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.
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.
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
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.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
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.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Great, thanks again![:) :)](https://open.vanillaforums.com/plugins/emojiextender/emoji/little/smile.png)
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.
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.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Oh, yes, naturally. Made the changes again, but within theme folder. Feel like a total idiot now...![:D :D](https://open.vanillaforums.com/plugins/emojiextender/emoji/little/grin.png)
No wonder I didn't see any changes previously. Works like a charm!