plugged in filtered pagination for entry pages

This commit is contained in:
Ro 2021-04-08 15:27:05 -07:00
parent 6c3653277d
commit 8e9b6ac422
5 changed files with 42 additions and 12 deletions

View file

@ -17,18 +17,20 @@ class DashControl
$template = ""; $template = "";
switch (isset($args["second"]) ? $args["second"] : "index") { switch (isset($args["second"]) ? $args["second"] : "index") {
case "pages": case "pages":
$data = (new Book("../content/pages"))->getPages(1, 4); $currentPage = isset($args["fourth"]) ? $args["fourth"] : 1;
$data = (new Book("../content/pages"))->getPages($currentPage, 4);
$template = "dash/book.twig"; $template = "dash/book.twig";
$pageOptions = [ $pageOptions = [
"entryCount" => $data["entryCount"], "entryCount" => $data["entryCount"],
"filter" => $data["sort"], "numOfPages" => $data["numOfPages"],
"currentPage" => $currentPage,
"filter" => $data["paginate"]["sort"],
"stats" => $data["stats"], "stats" => $data["stats"],
"pages" => $data["pages"], "pages" => $data["pages"],
"paginate" => $data["paginate"],
]; ];
break; break;
default: default:
//$_SESSION["TEST"] = "TESTERZ";
//session_unset();
$template = "dash/start.twig"; $template = "dash/start.twig";
if (Session::active()) { if (Session::active()) {
$pageOptions = [ $pageOptions = [

View file

@ -33,7 +33,6 @@ class Book
return $item["published"] == "true"; return $item["published"] == "true";
}); });
$deleted = filter($content, function ($item) { $deleted = filter($content, function ($item) {
//echo $item["deleted"];
return $item["deleted"]; return $item["deleted"];
}); });
@ -65,19 +64,33 @@ class Book
} }
$range = $page * $limit - $limit; $range = $page * $limit - $limit;
for ($i = 0; $i <= $limit; $i++) { for ($i = 0; $i <= $limit; $i++) {
try { if (isset($filtered[$i + $range])) {
array_push($folder, $filtered[$i + $range]); array_push($folder, $filtered[$i + $range]);
} catch (Exception $error) { } else {
//echo $error; //chill out
} }
} }
} }
$prev = $page - 1;
if ($prev <= 0) {
$prev = $numOfPages;
}
$next = $page + 1;
if ($next > $numOfPages) {
$next = 1;
}
return [ return [
"pages" => $folder, "pages" => $folder,
"numOfPages" => $numOfPages, "numOfPages" => $numOfPages,
"entryCount" => count($filtered), "entryCount" => count($filtered),
"sort" => $filter, "paginate" => [
"sort" => $filter,
"nextPage" => $next,
"prevPage" => $prev,
],
"stats" => [ "stats" => [
"all" => count($all), "all" => count($all),
"published" => count($published), "published" => count($published),

View file

@ -5,7 +5,7 @@
{% endblock %} {% endblock %}
{% block stylesheets %} {% block stylesheets %}
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=wrqrqrewq"> <link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=adfdfa">
{% endblock %} {% endblock %}
{% block mainContent %} {% block mainContent %}
@ -56,6 +56,21 @@
</div> </div>
</a> </a>
{% endfor %} {% endfor %}
{% if numOfPages > 1 %}
<div class="paginate">
<a class="page-btns" href="/dashboard/pages/{{ paginate['sort'] }}/{{ paginate['prevPage'] }}">
<svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-chevron-left"/></svg>
</a>
<span class="count">
{{ currentPage }}
of
{{ numOfPages }}
</span>
<a class="page-btns" href="/dashboard/pages/{{ paginate['sort'] }}/{{ paginate['nextPage'] }}">
<svg viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-chevron-right"/></svg>
</a>
</div>
{% endif %}
</div> </div>
</div> </div>

View file

@ -9,7 +9,7 @@
</div> </div>
</div> </div>
<br/> <br/>
{% if data["total"] != 0 %} {% if data["entryCount"] != 0 %}
{% for page in data['pages'] %} {% for page in data['pages'] %}
<a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="post-link" style="background: url({{ page.feature }}) no-repeat center center / cover"> <a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="post-link" style="background: url({{ page.feature }}) no-repeat center center / cover">
<div> <div>

View file

@ -122,7 +122,7 @@
padding: 5px padding: 5px
margin-top: -2px margin-top: -2px
display: inline-block display: inline-block
width: 200px width: 190px
font-size: 1.5em font-size: 1.5em
color: $tertiary color: $tertiary