Recent Topics

1 Mar 07, 2013 22:57    

I'm trying to create a blog which will pull entries from a database to display. I've got that part down, but I want to include pagination because there's a lot of entries. Is there a way to do that within the page? The code that I had can't reference php_SELF, so it doesn't work. Basicly, something like [url="http://dubird.net/free/setg.php"]this[/url].

2 Mar 08, 2013 03:02

well you need a limit for your pulled entries, say, $post_p_page = '8' var, to display 8 entries per page.
you should get total number of pulled posts by count($my_posts_query); , then set the page number like if($page_no == 0) $page_no = 1; ,so that you can repeat your $my_posts_query , but this time, end with the $offset $offset = ($page_no-1) * $post_p_page ; , $my_posts_query = .........LIMIT $post_p_page OFFSET $offset"

but from the link you posted, i see you've already sorted it out

3 Mar 08, 2013 05:21

No, the link I posted is not done in b2evolution. That's the current workup. I want to convert it fully to b2evo, and I've got everything worked out except the pagination. If it helps, I can post the current setup I've got.

4 Mar 08, 2013 06:12

why are you retrieving them manually anyway ? Why dont you just use a custom display ?

5 Mar 08, 2013 15:33

What do you mean, custom display? Like, a custom page? Right now it's a seperate database, but if there's a better way to display them with pagination by merging that table into my b2evo one, i can do so.

6 Mar 12, 2013 16:05

Just wondering if anyone else has insight into this. I'm perfectly willing to adapt what I have, I'm just not sure how to do it in a way that works with b2evo.

7 Mar 14, 2013 21:22

Ok, playing around and I finally got the links themselves to appear correctly. However, whenever I click one, it just defaults to the original page. Here's the page in question: http://www.dubird.net/index.php/jade/general-layouts

And here's how I have the code set up:

//////////// pagination
$getcount = mysql_query ("SELECT COUNT(*) FROM layouts WHERE CAT='generic'");
$postnum = mysql_result($getcount,0);
$limit = 7;
if($postnum > $limit){
$tagend = round($postnum % $limit,0);
$splits = round(($postnum - $tagend)/$limit,0);

if($tagend == 0){
$num_pages = $splits;
}else{
$num_pages = $splits + 1;
}

if(isset($_GET['pg'])){
$pg = $_GET['pg'];
}else{
$pg = 1;
}
$startpos = ($pg*$limit)-$limit;
$limstring = "LIMIT $startpos,$limit";
}else{
$limstring = "LIMIT 0,$limit";
}

///////////////// pagination links
if($postnum > $limit){

$n = $pg + 1;
$p = $pg - 1;
$thisroot = $_SERVER['PHP_SELF'];
if($pg > 1){
echo "<a href=\"$thisroot?pg=$p\"><< prev</a>&nbsp;&nbsp;";
}
for($i=1; $i<=$num_pages; $i++){
if($i!= $pg){
echo "<a href=\"$thisroot?pg=$i\">$i</a>&nbsp;&nbsp;";
}else{
echo "$i&nbsp;&nbsp;";
}
}
if($pg < $num_pages){
echo "<a href=\"$thisroot?pg=$n\">next >></a>";
}
echo "&nbsp;&nbsp;";
}
////////////// end pagination

The actual display will display correctly, the page links just don't do anything except reload the page.

9 Mar 15, 2013 15:17

Ok, had to go through all the tabs, but I found it under SEO. I unchecked all the "301 redirect to canonical URL when possible" but left the other one checked, and now it's working. Thanks for your help! ^_^

10 May 01, 2013 18:13

Update with new problem: This doesn't work on subdomains. Here's one of the pages in question: http://free.dubird.net/?title=anime-layouts-1&more=1&c=1&tb=1&pb=1 .

EDIT: Ok, playing around and found if I replace the "?pg=" with "&pg=", and use "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"].""; to determine the root it needs, it does work now! Granted, I still can't get the drop-down filter to work, but at least pagination works now.


Form is loading...