Move sortable page logic in Page class

This commit is contained in:
Giuseppe Criscione 2018-06-18 01:37:45 +02:00
parent 03ba1a77aa
commit 5baf18fe8e
2 changed files with 7 additions and 3 deletions

View File

@ -1,11 +1,10 @@
<ul class="pages-list <?= $class ?>" data-sortable="<?= $sortable ?>" <?php if ($parent): ?>data-parent="<?= $parent ?>"<?php endif; ?>>
<?php
foreach ($pages as $page):
$reorder = is_null($page->num()) || $page->template()->scheme()->get('num') == 'date';
$routable = $page->published() && $page->routable();
$date = date($this->option('date.format') . ' ' . $this->option('date.hour_format'), $page->lastModifiedTime());
?>
<li class="<?php if ($subpages): ?>pages-level-<?= $page->level() ?><?php endif; ?><?php if ($reorder): ?> not-sortable<?php endif; ?>">
<li class="<?php if ($subpages): ?>pages-level-<?= $page->level() ?><?php endif; ?><?php if (!$page->sortable()): ?> not-sortable<?php endif; ?>">
<div class="pages-item">
<div class="pages-item-cell page-details">
<div class="page-title">

View File

@ -34,7 +34,8 @@ class Page extends AbstractPage {
'published' => true,
'routable' => true,
'searchable' => true,
'cacheable' => true
'cacheable' => true,
'sortable' => true
);
}
@ -98,6 +99,10 @@ class Page extends AbstractPage {
// If the page isn't published, it won't also be visible
if (!$this->published()) $this->data['visible'] = false;
if (is_null($this->num()) || $this->template()->scheme()->get('num') == 'date') {
$this->data['sortable'] = false;
}
// Prepends the page uri if image uri doesn't start with '/', which means it isn't relative to the root
if ($this->has('image') && $this->image()[0] != '/') {
$this->data['image'] = $this->uri($this->image());