Showing certain things only for the first page

Hi there,

I want to list episodes of a podcast on my page like this:

<?php $episodes = $pages->find('episodes')->children()->visible()->sortBy('date', 'desc')->paginate(10)?>

Works…

Now I want to show a certain block of HTML only for the latest post. Trying:

<?php if($episodes->pagination()->isFirstPage()): ?>
…
<?php endif ?>

Sadly what is in the if statement is shown in every post. Why? :wink:

Thanks for help.

/marc

This on the other hand works perfectly fine on the same page:

<?php if($episodes->pagination()->hasPrevPage()): ?>
      <a class="button prev" href="<?php echo $episodes->pagination()->prevPageURL() ?>">&lsaquo;&lsaquo; newer entries</a>
<?php endif ?>

If you want to show it only for the first episode on the page, $pages->first() is what you want to compare to, something like:

<?php foreach($episodes as $episode): ?>
  <?php if($episode->is($episodes->first())): ?>
    …
  <?php endif ?>
<?php endforeach ?>

Works perfectly, Sonja. Thanks. Only one bracket is missing in your if statement:

<?php if($episode->is($episodes->first())): ?>

Have a nice evening.

/marc

Oh, yes, sorry, Marc, I have corrected it above (I’m afraid, I always have a problem with the number of parentheses outside my editor :blush:)