PHP code example of agence-adeliom / lumberjack-pagination
1. Go to this page and download the library: Download agence-adeliom/lumberjack-pagination library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
agence-adeliom / lumberjack-pagination example snippets
namespace App\PostTypes;
use Rareloop\Lumberjack\Post as BasePost;
use Adeliom\Lumberjack\Pagination\Pagination;
class Post extends BasePost
{
use Pagination;
}
namespace App;
use Adeliom\Lumberjack\Pagination\PaginationViewModel;
use App\Http\Controllers\Controller;
use Rareloop\Lumberjack\Http\Responses\TimberResponse;
use App\PostTypes\Post;
use Timber\Timber;
class IndexController extends Controller
{
public const RESULTS_PER_PAGE = 10;
public function handle(): TimberResponse
{
global $paged;
if (!isset($paged) || !$paged) {
$paged = 1;
}
$context = Timber::get_context();
$context['posts'] = Post::paginate(self::RESULTS_PER_PAGE);
$context['pagination'] = PaginationViewModel::fromQueryBuilder(self::RESULTS_PER_PAGE, $paged);
return new TimberResponse(['page/index.html.twig'], $context);
}
}