Pagination - page children / orphan pages

Post Reply
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

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.
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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...
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

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)
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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?
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

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

Code: Select all

$Site->itemsPerPage();

I'm having problems with that.
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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. ;-)
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

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.
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

Anyone has a method for paginating page children? I'll settle for next / previous links :)
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
Post Reply