1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-04 21:27:41 +02:00

Version 1.4.5: Cyanine Pagination for posts, option to list posts on startpage

This commit is contained in:
trendschau
2021-03-20 11:39:06 +01:00
parent 7ab3c68ef5
commit 904a56ecc5
6 changed files with 179 additions and 5 deletions

View File

@@ -33,6 +33,7 @@ class PageController extends Controller
$item = false;
$home = false;
$breadcrumb = false;
$currentpage = false;
$pathToContent = $this->settings['rootPath'] . $this->settings['contentFolder'];
$cache = new WriteCache();
$uri = $request->getUri()->withUserInfo('');
@@ -112,6 +113,35 @@ class PageController extends Controller
# use the structure as navigation if there is no difference
$navigation = $structure;
}
# start pagination
if(isset($args['params']))
{
$argSegments = explode("/", $args['params']);
# check if the last url segment is a number
$pageNumber = array_pop($argSegments);
if(is_numeric($pageNumber) && $pageNumber < 10000)
{
# then check if the segment before the page is a "p" that indicates a paginator
$pageIndicator = array_pop($argSegments);
if($pageIndicator == "p")
{
# use page number as current page variable
$currentpage = $pageNumber;
# set empty args for startpage
$args = [];
# if there are still params
if(!empty($argSegments))
{
# add them to the args again
$args['params'] = implode("/", $argSegments);
}
}
}
}
# if the user is on startpage
$home = false;
@@ -317,7 +347,8 @@ class PageController extends Controller
'base_url' => $base_url,
'image' => $firstImage,
'logo' => $logo,
'favicon' => $favicon
'favicon' => $favicon,
'currentpage' => $currentpage
]);
}

103
themes/cyanine/blog.twig Normal file
View File

@@ -0,0 +1,103 @@
<main class="{{ item.elementType }} w-100 pb5 bl br bb">
<div class="w-100 center grid-container">
<aside class="grid-header ph3 pv3">
<header>
<div class="logo">
<p class="pa0 ma0">
<a class="link f1 fw9" href="{{ base_url }}" title="My Title">
{% if logo %}
<img src="{{ base_url }}/{{ logo }}" class="logo-image"/>
{% else %}
{{ settings.title }}
{% endif %}
</a>
</p>
</div>
</header>
{% if widgets %}
{% for index,widget in widgets %}
<div id="{{ index }}" class="mt4-l mt3">
{{ widget }}
</div>
{% endfor %}
{% endif %}
</aside>
<div class="grid-main ph3 ph4-l pv3 lh-copy f4 fw3">
{% if settings.themes.cyanine.blogintro %}
<article>
<header>
<h1>{{ title }}</h1>
</header>
{{ content }}
</article>
{% endif %}
{% set pagelist = getPageList(navigation, settings.themes.cyanine.blogfolder, base_url) %}
{% set pages = ( pagelist.folderContent|length / 2)|round(0, 'ceil') %}
{% set currentpage = currentpage ? currentpage : 1 %}
{% set currentposts = (currentpage - 1) * 2 %}
<ul class="post list pa0">
{% for element in pagelist.folderContent|slice(currentposts, 2) %}
{% set post = getPageMeta(settings, element) %}
{% set date = element.order[0:4] ~ '-' ~ element.order[4:2] ~ '-' ~ element.order[6:2] %}
<li class="post-entry">
<header>
<a class="link f-link underline-hover" href="{{ element.urlAbs }}"><h2 class="mt4 mb2">{{ post.meta.title }}</h2></a>
<div class="mt3"><small><time datetime="{{date}}">{{ date | date("d.m.Y") }}</time> | {{ post.meta.author }}</small></div>
</header>
<p>{{ post.meta.description }}</p>
</li>
{% endfor %}
{% if pages > 1 %}
<hr class="mv4">
<p>Page:
{% for i in 1 .. pages %}
{% if i == currentpage %}
{{i}}
{% else %}
<a class="page" href="{{ item.urlAbs }}/p/{{i}}">{{i}}</a>
{% endif %}
{% endfor %}
</p>
{% endif %}
</ul>
</div>
<aside class="grid-sidebar ph3 pv3">
<nav id="contentnav" class="contentnav{{ settings.themes.cyanine.collapseNav ? ' collapse' : '' }}" aria-label="Menu">
<!-- burger menu controlled by invisible checkbox -->
<input type="checkbox" id="burger" class="dn">
<label for="burger" class="burgerbutton">&#9776;</label>
{% include 'partials/navigation.twig' %}
</nav>
</aside>
</div>
</main>

View File

@@ -26,9 +26,28 @@ forms:
large: Large
full: Full Width
blog:
type: checkbox
checkboxlabel: Activate a List of Posts on Homepage
blogdetails:
type: fieldset
legend: Configure List of Posts
fields:
blogintro:
type: checkbox
label: Intro Page
checkboxlabel: Show the content of the homepage before the list of posts
blogfolder:
type: text
label: Enter the folder path with the posts
placeholder: /blog
landingpage:
type: checkbox
checkboxlabel: Activate a landingpage
checkboxlabel: Activate a Landing Page on Homepage
landingpageIntro:
type: fieldset

View File

@@ -7,6 +7,10 @@
{% if home and settings.themes.cyanine.landingpage %}
{% include 'home.twig' %}
{% elseif home and settings.themes.cyanine.blog %}
{% include 'blog.twig' %}
{% else %}

View File

@@ -51,7 +51,7 @@
grid-template-columns: 25% 75%;
}
.grid-main{
max-width: 56rem;
max-width: 48rem;
margin: 0 auto;
}
}
@@ -64,7 +64,7 @@
.grid-main{
padding-left: 4rem;
padding-right: 4rem;
margin: auto;
margin: 0 auto;
}
}
{% else %}

View File

@@ -1,6 +1,10 @@
{% set pages = ( item.folderContent|length / 2)|round(0, 'ceil') %}
{% set currentpage = currentpage ? currentpage : 1 %}
{% set currentposts = (currentpage - 1) * 2 %}
<ul class="post list pa0">
{% for element in item.folderContent %}
{% for element in item.folderContent|slice(currentposts, 2) %}
{% set post = getPageMeta(settings, element) %}
{% set date = element.order[0:4] ~ '-' ~ element.order[4:2] ~ '-' ~ element.order[6:2] %}
@@ -15,4 +19,17 @@
{% endfor %}
{% if pages > 1 %}
<hr class="mv4">
<p>Page:
{% for i in 1 .. pages %}
{% if i == currentpage %}
{{i}}
{% else %}
<a class="page" href="{{ item.urlAbs }}/p/{{i}}">{{i}}</a>
{% endif %}
{% endfor %}
</p>
{% endif %}
</ul>