[SOLVED] Pagination

Post Reply
ctuxboy
Ssr. Bludit
Posts: 25
Joined: Sat Dec 15, 2018 11:37 pm
Has thanked: 4 times
Been thanked: 2 times

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 17034 times
Last edited by ctuxboy on Thu Jan 05, 2023 8:22 pm, edited 1 time in total.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

No, not yet. You have to code it. And it's an idea for a plugin.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
ctuxboy
Ssr. Bludit
Posts: 25
Joined: Sat Dec 15, 2018 11:37 pm
Has thanked: 4 times
Been thanked: 2 times

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 ;)
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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!
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
ctuxboy
Ssr. Bludit
Posts: 25
Joined: Sat Dec 15, 2018 11:37 pm
Has thanked: 4 times
Been thanked: 2 times

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 17019 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/
User avatar
Misteric
Ssr. Bludit
Posts: 13
Joined: Mon Aug 08, 2022 2:55 pm
Has thanked: 2 times
Been thanked: 4 times

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 } ?>
		
medicamin
Jr. Bludit
Posts: 6
Joined: Fri Sep 15, 2023 1:24 pm
Has thanked: 2 times
Been thanked: 2 times

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 16574 times
Screenshot_02-06-27_19-32-50.jpg
Screenshot_02-06-27_19-32-50.jpg (5.8 KiB) Viewed 16574 times
Screenshot_02-06-27_19-33-04.jpg
Screenshot_02-06-27_19-33-04.jpg (6.94 KiB) Viewed 16574 times
Post Reply