Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
20.3k views
in Q2A Core by
edited by

Folling up with this question: http://www.question2answer.org/qa/21532/is-there-any-way-to-paginate-activity-page

I am suggesting this workaround for pagination of activity page. Many of us need pagination of activity page for the follwoing reasons:

1 - We want to set the frontpage to be activity page so that our visitors get to see more often updates, once they open our website. We don't want them to open the home page and bounce back and walk, right?

2- at the same time we wanna show them the many pages of the questions posted on our qa forum (1 2 ...2000 Next) so that they know that our qa forum is busy.

3- also we only need the default page (front page) to display the most recent activities.The reason is item 1 mentioned above ( we dont want the visitors to see the frontpage and see nothing new from past 24 hours.

At the same time we know that pagination is only available for the list of questions (question2answer.org/qa/questions)

So my suggestion is to combine the two in the following way:

1- set the default page(front page) to question2answer.org/qa/activity using this method http://www.question2answer.org/qa/20896/how-to-set-the-frontpage-to-be-mydomain-com-qa-questions

2- add a code to display the followng view model at the top of only front page:( I dont know how to do this part)

where page 0 being selected means the current page is frontpage which contains the most recent activity and clicking on the the rest of page numbers takes us to the correcponding page of question2answer.org/qa/questions.

clicking on any of thoese numbers will take us the question2answer.org/qa/questions which is already paginated.

So all I wanted to do was to bring this

to the front page. Can we do that?

Q2A version: Q2A 1.5.4
by
Well put! 2 notes:

I still have the default page (qa) as front page, but added comments to it. See http://www.question2answer.org/qa/21314/ This is sufficient for all users. (Activity shows edit and tagged notices that no normal user needs.). This is why I vote for just adding comments events to main page and add pagination based on that.

quote: "2- add a code to display the followng view model at the top of only front page"
I am quite sure you could bring up the pagination div from bottom to top with CSS.
by
1- I agree with that, however time is tight. I wanted a faster solution as you mentioned you are busy. I have to decrease the bounce rate for my new forum.
2- Yes, you are right. I already did that after learning the howto by asking this question http://www.question2answer.org/qa/20897 . Plz refer to Scot's answer "as for copying the links at the top, that is done in an advanced theme. In the main() function, you'll see $this->page_links() towards the end. Just copy that line and put it further up, anywhere above main_parts() should work."

2 Answers

+1 vote
by
selected by
 
Best answer

I dont know how to have the real questions number on front page, but if it is ok for You to show 0, 1, 2, 3 more or 0,1,2,3,4,5,6,7,8,9,more You can copy the following two functions to Your qa-theme.php

That would do it. Just once on a questions page the preview tab is not prefectly positioned... but for a work around it should be ok.

Now, please review it Yourself and optimize the code...

 

 

function page_links()
{
$page_links=@$this->content['page_links'];
 
if (!empty($page_links)) {
$this->output('<DIV CLASS="qa-page-links">');
 
$this->page_links_label(@$page_links['label']);
$this->page_links_list(@$page_links['items']);
$this->page_links_clear();
 
$this->output('</DIV>');
//added the else if which shows a fake pagination when You are on activity or qa page 
//THAT DEPENDS on which homepage You are linking to through the configuration file.
}elseif ((($this->template=='qa')||($this->template=='activity'))&& (empty($this->content['categoryids']))){
// Edited the line above to make sure that on category pages the fake pagination does not show up
//}elseif (($this->template=='qa')||($this->template=='activity')){
$this->output('<DIV CLASS="qa-page-links">');
$this->output('<SPAN CLASS="qa-page-links-label">Pages</SPAN>');
$this->output('<UL CLASS="qa-page-links-list">');
$this->output('<LI CLASS="qa-page-links-item">');
$this->output('<SPAN CLASS="qa-page-selected">0</SPAN>');
$this->output('</LI>');
$this->output('<LI CLASS="qa-page-links-item">');
$this->output('<A HREF="../questions" CLASS="qa-page-link">1</A>');
$this->output('</LI>');
$this->output('<LI CLASS="qa-page-links-item">');
$this->output('<A HREF="../questions?start=20" CLASS="qa-page-link">2</A>');
$this->output('</LI>');
$this->output('<LI CLASS="qa-page-links-item">');
$this->output('<A HREF="../questions?start=40" CLASS="qa-page-link">3</A>');
$this->output('</LI>');
$this->output('<LI CLASS="qa-page-links-item">');
$this->output('<A HREF="../questions" CLASS="qa-page-next">next &raquo;</A>');
$this->output('</LI>');
$this->output('</UL>');
$this->page_links_clear();
$this->output('</DIV>');
 
 
}else{
}
}
 
function page_links_list($page_items)
{
if (!empty($page_items)) {
$this->output('<UL CLASS="qa-page-links-list">');
 
//six lines added
//setting a new page link to 0 with a link to the matching page ../activity here
if($this->template=='questions'){
$this->output('<LI CLASS="qa-page-links-item">');
//where to link depends on which pages you have activated and which one is set as homepage try ../activity or ../
$this->output('<A HREF="../activity" CLASS="qa-page-link">0</A>');
$this->output('</LI>');
}else{}
 
 
$index=0;
 
foreach ($page_items as $page_link) {
$this->set_context('page_index', $index++);
$this->page_links_item($page_link);
 
if ($page_link['ellipsis'])
$this->page_links_item(array('type' => 'ellipsis'));
}
 
$this->clear_context('page_index');
 
$this->output('</UL>');
}
}
 
 
--------------------------------------
 
It does work well but is not really correct. So if You choose on questions page sorted by answers or votes the content of page 0 remains the same. thatfore i think it is ok to have the 0 left of the prev tab. Let me know what You think, may be we can make it better.
 
 
EDIT 1
 
I have edited  the following line in the code above. Otherwise the pagination would show up on mypage.com/category1/...
 
}elseif ((($this->template=='qa')||($this->template=='activity'))&& (empty($this->content['categoryids']))){
 
 
 
by
The pagination in the "hack" above targets the /questions/ page, and not the list from qa or activity :(
by
It is that what was asked for:

"......where page 0 being selected means the current page is frontpage which contains the most recent activity and clicking on the the rest of page numbers takes us to the correcponding page of question2answer.org/qa/questions....."

If You need to link to qa/questions instead of questions just change the links. Same for qa/activity instead of activity. Or change the url structure in admin /general

Where is Your problem ?
by
I was thinking of the other recent issue, i.e. pagination of main page, e.g. http://www.question2answer.org/qa/?start=200 never mind ;)
by
A follow up with monk333's comment where mentions "but this is only suitable if the exsting categries allready have enough questions":
Is there  any way to learn the number of question posted within the code of qa-theme.php?
cuz if we can do so, we can perfectly display all the page numbers on the frontpage correctly ( not just very first three). More importantly, even not having enough number of questions would not be a problem :) mann that would be perfect!
–1 vote
by
Page numbers are hard coded in the solution above. It is not a generic solution. Not always the page sizes are 20! A good start thought.
...