Page 1 of 1

[SOLVED] Pagination

Posted: Wed Jan 04, 2023 11:37 pm
by ctuxboy
On my blog, there are the 'default' bludit pagination buttons Home, Back and Previous

Is there a simple way / code snippet example adding also page-numbers between this pagination-buttons, similar like this:
Screenshot 2023-01-04 23.37.03.png
Screenshot 2023-01-04 23.37.03.png (4.6 KiB) Viewed 18651 times

Re: pagination

Posted: Thu Jan 05, 2023 12:46 pm
by Edi
No, not yet. You have to code it. And it's an idea for a plugin.

Re: pagination

Posted: Thu Jan 05, 2023 7:28 pm
by ctuxboy
Edi wrote: Thu Jan 05, 2023 12:46 pm No, not yet. You have to code it. And it's an idea for a plugin.
Hi @Edi, thanks for your reply :)
Found some themes that have this pagination-function, so i'm looking to the code from this themes, hope found how they do it ;)

Re: pagination

Posted: Thu Jan 05, 2023 7:57 pm
by Edi
ctuxboy wrote: Thu Jan 05, 2023 7:28 pm Found some themes that have this pagination-function, so i'm looking to the code from this themes, hope found how they do it ;)
Interesting, I wasn't aware of it!

Re: pagination

Posted: Thu Jan 05, 2023 8:20 pm
by ctuxboy
Edi wrote: Thu Jan 05, 2023 7:57 pm
ctuxboy wrote: Thu Jan 05, 2023 7:28 pm Found some themes that have this pagination-function, so i'm looking to the code from this themes, hope found how they do it ;)
Interesting, I wasn't aware of it!
Yes, some themes have nice options where can learn a lot. i love it ;)
In the meanwhile ported a pagination-function from a theme; do a little customation (css) and it works now :)
Screenshot 2023-01-05 20.05.20.png
Screenshot 2023-01-05 20.05.20.png (17.86 KiB) Viewed 18636 times
Screenshot: Above the default pagination-function, below the better pagination-function

You can see the result on the bottom of my website: https://gewoonsimpel.be/

Re: [SOLVED] Pagination

Posted: Sun Jul 09, 2023 10:01 am
by Misteric
A pagination script with numbers, first and last button:

Code: Select all

<?php 
	if(!isset($_GET['page'])){
		$getPage = 1;
	} else {
		$getPage = $_GET['page'];
	} 
	?>
	<ul class="list-group flex-md-row">
		<?php if($getPage != 1) { ?>
		<li class="list-group-item">
			<a class="btn btn-dark" href="<?php echo Theme::siteUrl(); ?>?page=1">First</a>
		</li>
		<?php } ?>
		<?php if ($getPage >= 3) { ?>
		<li class="list-group-item">
			<a class="btn btn-dark" href="<?php echo Theme::siteUrl(); ?>?page=<?php echo $getPage - 2; ?>"><?php echo $getPage - 2; ?></a>
		</li>
		<?php } ?>
		<?php if ($getPage >= 2) { ?>
		<li class="list-group-item">
			<a class="btn btn-dark" href="<?php echo Theme::siteUrl(); ?>?page=<?php echo $getPage - 1; ?>"><?php echo $getPage - 1; ?></a>
		</li>
		<?php } ?>
		<?php if ($getPage) { ?>
		<li class="list-group-item">
			<a class="btn btn-warning" href="<?php echo Theme::siteUrl().'?page='.$getPage; ?>"><?php echo $getPage; ?></a>
		</li>
		<?php } ?>
		<?php if (Paginator::numberOfPages()-1 >= $getPage) { ?>
		<li class="list-group-item">
			<a class="btn btn-dark" href="<?php echo Theme::siteUrl().'?page='.$getPage + 1; ?>"><?php echo $getPage + 1; ?></a>
		</li>
		<?php } ?>
		<?php if (Paginator::numberOfPages()-2 >= $getPage) { ?>
		<li class="list-group-item">
			<a class="btn btn-dark" href="<?php echo Theme::siteUrl().'?page='.$getPage + 2; ?>"><?php echo $getPage + 2; ?></a>
		</li>
		<?php } ?>
		<?php if(Paginator::numberOfPages() != $getPage) { ?>
		<li class="list-group-item">
			<a class="btn btn-dark" href="<?php echo Theme::siteUrl().'?page='.Paginator::numberOfPages(); ?>">Last</a>
		</li>;
		<?php } ?>
		

Re: [SOLVED] Pagination

Posted: Mon Sep 18, 2023 8:49 am
by medicamin
I modified some parts of the above code to make it work in blogx theme.
below code works in category and tag pages too. And also adds some dots (...) after first and before the last page.

Code: Select all

<?php 
	if(!isset($_GET['page'])){
		$getPage = 1;
	} else {
		$getPage = $_GET['page'];
	} 
	?>
	<ul class="list-group flex-md-row">
    
		<?php if ($getPage >= 4) { ?>
		<li class="list-group-item">
			<a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>">Firsta>
		</li>
        <li>...&nbsp;</li>
        <?php } ?>
        
		<?php if ($getPage >= 3) { ?>
		<li class="list-group-item">
			<a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>
?page=<?php echo $getPage - 2; ?>"><?php echo $getPage - 2; ?></a>
		</li>
		<?php } ?>
        
		<?php if ($getPage >= 2) { ?>
		<li class="list-group-item">
			<a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>
?page=<?php echo $getPage - 1; ?>"><?php echo $getPage - 1; ?></a>
		</li>
		<?php } ?>
        
		<?php if ($getPage) { ?>
		<li class="list-group-item">
			<a class="btn btn-selected" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>
?page=<?php echo $getPage; ?>"><?php echo $getPage; ?></a>
		</li>
		<?php } ?>
       
		<?php if (Paginator::numberOfPages()-1 >= $getPage) { ?>
		<li class="list-group-item">
			<a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>
?page=<?php echo $getPage + 1; ?>"><?php echo $getPage + 1; ?></a>
		</li>
        
		<?php } ?>
		<?php if (Paginator::numberOfPages()-2 >= $getPage) { ?>
		<li class="list-group-item">
			<a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>?page=<?php echo $getPage + 2; ?>"><?php echo $getPage + 2; ?></a>
		</li>
		<?php } ?>
         
        
        <?php if (Paginator::numberOfPages()-3 >= $getPage) { ?>
		<li>...&nbsp;</li>
        <li class="list-group-item">
			<a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?page='.Paginator::numberOfPages(); ?>">Last</a>
		</li>
		<?php } ?>
and this is CSS I used with the above code + in blogx theme:

Code: Select all

.list-group-item {
    position: relative;
    display: inline-block;
    padding: 0; 
    background-color: #fff;
    border: none; 
    margin: 0 4px 10px 0px;
}

.btn {
    padding: 2px 10px 0 10px;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: 3px;
    font-size: 17px;
	}

.btn-selected,
.btn:hover {
    color: #fff;
    background-color: #036BAA;
    font-weight:600;
}
Screenshot_02-06-27_19-32-32.jpg
Screenshot_02-06-27_19-32-32.jpg (4.72 KiB) Viewed 18191 times
Screenshot_02-06-27_19-32-50.jpg
Screenshot_02-06-27_19-32-50.jpg (5.8 KiB) Viewed 18191 times
Screenshot_02-06-27_19-33-04.jpg
Screenshot_02-06-27_19-33-04.jpg (6.94 KiB) Viewed 18191 times