Im full of beer and chinese food at this point in the evening so im stuggling to explain
bascially you run into the next and previous links linking to the wrong image if you reorder the files because then it is out of sync with the virtual page numbering… am i making sense?
sander
January 17, 2021, 9:22pm
22
But as long as I don’t reorder the images in the panel, just keep the original order?
texnixe
January 17, 2021, 9:24pm
23
Model:
public function children()
{
$images = [];
foreach ($this->images() as $image) {
$images[] = [
'slug' => $image->name(),
'num' => $image->sort()->isNotEmpty() ? $image->sort()->value() : null,
'template' => 'image',
'model' => 'image',
'content' => [
'sort' => $image()->sort(),
]
];
}
return Pages::factory($images, $this);
}
Controller:
$gallery = $page->children()->sortBy('sort');
Prev-next
<?php
$siblings = $page->siblings()->sortBy('sort');
if ($page->hasNext($siblings): ?>
<a href="<?= $page->next($siblings)->url() ?>" aria-label="Next">→</a>
<?php else: ?>
<span>→</span>
<?php endif ?>
That would be good… … if you can add the ability to do this and make a real sub page too, that would be awesome. Right now, you cant with this setup.