forked from projects/fipamo
plugged in filtered pagination for entry pages
This commit is contained in:
parent
6c3653277d
commit
8e9b6ac422
5 changed files with 42 additions and 12 deletions
|
@ -17,18 +17,20 @@ class DashControl
|
|||
$template = "";
|
||||
switch (isset($args["second"]) ? $args["second"] : "index") {
|
||||
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";
|
||||
$pageOptions = [
|
||||
"entryCount" => $data["entryCount"],
|
||||
"filter" => $data["sort"],
|
||||
"numOfPages" => $data["numOfPages"],
|
||||
"currentPage" => $currentPage,
|
||||
"filter" => $data["paginate"]["sort"],
|
||||
"stats" => $data["stats"],
|
||||
"pages" => $data["pages"],
|
||||
"paginate" => $data["paginate"],
|
||||
];
|
||||
break;
|
||||
default:
|
||||
//$_SESSION["TEST"] = "TESTERZ";
|
||||
//session_unset();
|
||||
$template = "dash/start.twig";
|
||||
if (Session::active()) {
|
||||
$pageOptions = [
|
||||
|
|
|
@ -33,7 +33,6 @@ class Book
|
|||
return $item["published"] == "true";
|
||||
});
|
||||
$deleted = filter($content, function ($item) {
|
||||
//echo $item["deleted"];
|
||||
return $item["deleted"];
|
||||
});
|
||||
|
||||
|
@ -65,19 +64,33 @@ class Book
|
|||
}
|
||||
$range = $page * $limit - $limit;
|
||||
for ($i = 0; $i <= $limit; $i++) {
|
||||
try {
|
||||
if (isset($filtered[$i + $range])) {
|
||||
array_push($folder, $filtered[$i + $range]);
|
||||
} catch (Exception $error) {
|
||||
//echo $error;
|
||||
} else {
|
||||
//chill out
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$prev = $page - 1;
|
||||
if ($prev <= 0) {
|
||||
$prev = $numOfPages;
|
||||
}
|
||||
|
||||
$next = $page + 1;
|
||||
if ($next > $numOfPages) {
|
||||
$next = 1;
|
||||
}
|
||||
|
||||
return [
|
||||
"pages" => $folder,
|
||||
"numOfPages" => $numOfPages,
|
||||
"entryCount" => count($filtered),
|
||||
"sort" => $filter,
|
||||
"paginate" => [
|
||||
"sort" => $filter,
|
||||
"nextPage" => $next,
|
||||
"prevPage" => $prev,
|
||||
],
|
||||
"stats" => [
|
||||
"all" => count($all),
|
||||
"published" => count($published),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
|
||||
{% block mainContent %}
|
||||
|
@ -56,6 +56,21 @@
|
|||
</div>
|
||||
</a>
|
||||
{% 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>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
{% if data["total"] != 0 %}
|
||||
{% if data["entryCount"] != 0 %}
|
||||
{% 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">
|
||||
<div>
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
padding: 5px
|
||||
margin-top: -2px
|
||||
display: inline-block
|
||||
width: 200px
|
||||
width: 190px
|
||||
font-size: 1.5em
|
||||
color: $tertiary
|
||||
|
||||
|
|
Loading…
Reference in a new issue