<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
heimrichhannot / contao-news-pagination-bundle example snippets
use HeimrichHannot\NewsPaginationBundle\Util\PaginationUtil;
use Wa72\HtmlPageDom\HtmlPageCrawler;
class ParseArticlesListener {
/** @var PaginationUtil */
protected $paginationUtil;
public function __invoke(FrontendTemplate $template, array $newsEntry, Module $module) {
$result = $this->paginationUtil->paginateHtmlText($template->text, 500, 1, [
'selector' => '.ce_text_custom div.text',
'removePageElementsCallback' => function (array $result, int $currentPage, int $page) {
// Always show page 1
if (1 === $page) {
return false;
}
// Insert custom html after page 3
if (3 === $page) {
$someCustomInsertion = new HtmlPageCrawler('<div class="alert">Custom Notice!</div>');
$someCustomInsertion->insertAfter(end($result[$page])['element']);
}
// Remove all element not on the current page (default)
return $page != $currentPage;
}
]);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.