medienbaecker / kirby-modules

Plugin for modular Kirby websites
MIT License
73 stars 7 forks source link

Bug? Modules plugin breaks pagination #10

Closed hariom147 closed 4 years ago

hariom147 commented 4 years ago

I have tested modules on an installation and noticed, that it breaks pagination (as can be seen here: https://hanuman-chalisa.net/en/projects - a test installation). Error occurs, when clicking on "2" or ">", debugging is activated.

I only figured it was caused by the modules plugin, because further down in the list of stack frames (#7) it lists the modules plugin. Everything else is too advanced for me...

Maybe it is also caused by my setup - I use a theme, that uses the Kirby pagebuilder plugin.

medienbaecker commented 4 years ago

What does your pagination code look like? I would be very surprised if the modules plugin could cause this. It seems like there is no „page 2“ but it’s visible in the pagination menu.

hariom147 commented 4 years ago

As I am new to Kirby and not very experienced in coding, I'll just post the code in the pagination snippet. I also wouldn't have thought of the modules plugin causing the error, but when deleting the modules plugin folder, the error doesn't occur anymore... Funny is also, that I haven't use code to display modultes in the page-template nor in the page-blueprint...

But if this is too weird, I can just closing this issue, since I do not have to rely on the modules plugin for further development...

<?php if($page->paginate()->isNotEmpty() and $pagination->total() > $page->paginate()->int()): ?>
<div class="content">
  <nav class="pagination <?php e($page->listview()->bool(), 'list-pagination') ?>" aria-labelledby="<?= $aria ?>">
    <h2 class="pagination-heading sr-only" id="<?= $aria ?>">
      <?php e($site->pagination()->isNotEmpty(), $site->pagination(), 'Pagination'); ?>
    </h2>
      <ol>
        <?php if ($pagination->hasPrevPage()): ?>
          <li class="pagination-prev">
            <a href="<?= $pagination->prevPageURL() ?>#page" title="<?php e($site->previous()->isNotEmpty(), $site->previous(), 'Previous'); ?>">
              ‹ 
              <span class="sr-only">
                <?php e($site->previous()->isNotEmpty(), $site->previous(), 'Previous'); ?>
              </span>
            </a>
          </li>
        <?php else: ?>
          <li class="pagination-none">
            <span> 
              – 
              <span class="sr-only">
                <?php e($site->noprevious()->isNotEmpty(), $site->noprevious(), 'No previous'); ?>
              </span>
            </span>
          </li>
        <?php endif ?>

        <?php foreach ($range as $r): ?>
          <li>
            <a<?= $pagination->page() === $r ? ' aria-current="page" class="pagination-current"' : '' ?> href="<?= $pagination->pageURL($r) . '#page' ?>">
              <?= $r ?>
            </a>
          </li>
        <?php endforeach ?>

        <?php if ($pagination->hasNextPage()): ?>
          <li class="pagination-next">
            <a href="<?= $pagination->nextPageURL() ?>#page" title="<?php e($site->next()->isNotEmpty(), $site->next(), 'Next'); ?>">
              <span class="sr-only">
                <?php e($site->next()->isNotEmpty(), $site->next(), 'Next'); ?>
              </span> 
              ›
            </a>
          </li>
        <?php else: ?>
          <li class="pagination-none">
            <span>
              – 
              <span class="sr-only">
                <?php e($site->nonext()->isNotEmpty(), $site->nonext(), 'No next'); ?>
              </span>
            </span>
          </li>
        <?php endif ?>
      </ol>
  </nav>
</div>
<?php endif ?>
medienbaecker commented 4 years ago

Super weird indeed. I'm going to paste a screenshot of the error message so you can continue developing your site while I try to understand what's going on.

image

medienbaecker commented 4 years ago

I could finally reproduce it with a plainkit:

https://backofen.link/modules_pagination_test/projects/page:2 https://backofen.link/modules_pagination_test.zip

It works flawlessly on home. On /projects it throws the exact same error. I don't see any difference dumping the $page->blueprint() object, though.

@afbora Do you have any idea what causes this issue?

afbora commented 4 years ago

@medienbaecker I'm on it.

medienbaecker commented 4 years ago

I discussed this with @afbora in the Kirby Slack. Unfortunately we didn't find a simple solution yet. (Thanks for your help, Ahmet!)

lukasbestle commented 4 years ago

Slack discussion for reference: https://getkirby.slack.com/archives/CBY2BA82E/p1585649881011700

I will take a look at this when I'm back at my computer, probably tomorrow.

medienbaecker commented 4 years ago

Until this is solved in the Kirby core I fixed it with a workaround in version 0.6.1.

bastianallgeier commented 4 years ago

We just merged the fix for this in the core. It will be in 3.4