Page 1 of 1
Pagination - page children / orphan pages
Posted: Tue Apr 10, 2018 4:36 am
by bayerberg
my page.php has
Code: Select all
if ($page->children()){
foreach ($page->children() as $page) {
if ($page->published()) {
echo'<h4 class="title"><a href="'.$page->permalink().'">'.$page->title().'</a></h4>';
echo'<p>'.$page->description().'</p>';
echo'<p><a href="'.$page->permalink().'">'.$Language->get('Read more').'</a></p>';
echo'<hr/>';
}
}
}
was trying to paginate it but failed. is there an easy way to reuse function already in use or do i have to write something from scratch?
related question
on home.php i want to show only pages without parents or children and paginate the result of foreach. If i do it using
Code: Select all
$pages = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
and then showing only the orphan ones the list
Code: Select all
$amountOfItems = $Site->itemsPerPage();
doesnt work properly - it counts everything. Is there a way of listing orphan pages and then paginating the result? I'm using static pages for something else so cant go that way.
Re: Pagination - page children / orphan pages
Posted: Tue Apr 10, 2018 3:12 pm
by Edi
bayerberg wrote: ↑Tue Apr 10, 2018 4:36 am
my page.php has
Code: Select all
if ($page->children()){
foreach ($page->children() as $page) {
if ($page->published()) {
echo'<h4 class="title"><a href="'.$page->permalink().'">'.$page->title().'</a></h4>';
echo'<p>'.$page->description().'</p>';
echo'<p><a href="'.$page->permalink().'">'.$Language->get('Read more').'</a></p>';
echo'<hr/>';
}
}
}
was trying to paginate it but failed. is there an easy way to reuse function already in use or do i have to write something from scratch?
What do you mean with pagination? Normally the pagination is a blog function, and blog posts have no child pages.
Re: Pagination - page children / orphan pages
Posted: Tue Apr 10, 2018 3:14 pm
by Edi
bayerberg wrote: ↑Tue Apr 10, 2018 4:36 am
on home.php i want to show only pages without parents or children and paginate the result of foreach. If i do it using
What is a page without a parent or a children? A page is a parent content or a child content...
Re: Pagination - page children / orphan pages
Posted: Tue Apr 10, 2018 6:35 pm
by bayerberg
yes, i want to paginate subpages. blog - thats done, but if I would like to create a product site pagination would be needed to limit how many sub-products are shown on one product page
btw.
as I see it there are 3 states of pages
parent - has children (top level)
child - has a parent (subpage)
orphan (top level) no children or parents, can be set as main landing page (index)
Re: Pagination - page children / orphan pages
Posted: Tue Apr 10, 2018 8:03 pm
by Edi
Okay, now I understand what you mean with an orphan.
An idea would be to do it with the position.
Do you have an example of this structure?
Re: Pagination - page children / orphan pages
Posted: Tue Apr 10, 2018 8:20 pm
by bayerberg
I'm using 2 templates for product pages
levelone.php (parent) and page.php (child)
level one looks like this
Code: Select all
<div class="container">
<div class="row">
<div class="twelve columns">
<h1 class="title">Level one : <?php echo $page->title(); ?></h1>
<?php if ($page->coverImage()): ?>
<img src="<?php echo $page->coverImage(); ?>" alt="<?php echo $page->title(); ?>" class="cover-image" />
<?php endif ?>
<?php if ($page->description()): ?>
<h3><?php echo $page->description(); ?></h3>
<?php endif ?>
<?php echo $page->content(); ?>
</div>
</div>
</div>
<?php
if ($page->children()){
echo'<div class="container">
<div class="row">
<div class="twelve columns">';
foreach ($page->children() as $child) {
if ($child->published()) {
echo'<h4 class="title"><a href="'.$child->permalink().'">'.$child->title().'</a></h4>';
echo'<p>'.$child->description().'</p>';
echo'<p><a href="'.$child->permalink().'">'.$Language->get('Read more').'</a></p>';
echo'<hr/>';
}
}
echo'</div>
</div>
</div>';
}
?>
<div class="container">
<div class="row">
<div class="four columns to-left">
<hr/>
<?php if (Paginator::amountOfPages()>1): ?>
<p><?php if (Paginator::showPrev()) {
echo '<a href="'.Paginator::prevPageUrl().'" tabindex="-1" class="paginator-button">'.$Language->get('Previous').'</a>';
} ?></p>
</div>
<div class="four columns to-middle">
<hr/><p>
<?php for ($i = 1; $i <= Paginator::amountOfPages(); $i++): ?>
<a class="paginator-button <?php if ($i==Paginator::currentPage()) echo 'active' ?>" href="<?php echo Paginator::numberUrl($i) ?>"><?php echo $i ?></a>
<?php endfor ?>
</p>
</div>
<div class="four columns to-right">
<hr/>
<?php if (Paginator::showNext()) {
echo '<p><a href="'.Paginator::nextPageUrl().'" class="paginator-button">'.$Language->get('Next').'</a></p>';
} ?>
<?php endif ?>
</div>
</div>
</div>
nothing out of the ordinary, normal page but there is one extra loop for children. now - i dont want to show all 30 sub-products so i wanted to paginate children using
I'm having problems with that.
Re: Pagination - page children / orphan pages
Posted: Wed Apr 11, 2018 12:03 pm
by Edi
It depends of the amount of pages... You can insert the links to the previous and the next page manually. Or use perhaps the position.
Is there a live example of this structure? Bludit is a CMS not a shop.
Re: Pagination - page children / orphan pages
Posted: Wed Apr 11, 2018 1:03 pm
by bayerberg
ill finish and publish the site, you'll get whats going on in an instant
btw. in terms of orphan pages (posts) - is there a way to loop only those? I want to show (and paginate) only those without parents or children in a separate part of the website.
Re: Pagination - page children / orphan pages
Posted: Sun Jun 18, 2023 1:23 am
by bayerberg
Anyone has a method for paginating page children? I'll settle for next / previous links