Skip to content

Instantly share code, notes, and snippets.

@danscotton
Last active December 17, 2015 05:08
Show Gist options
  • Save danscotton/5555250 to your computer and use it in GitHub Desktop.
Save danscotton/5555250 to your computer and use it in GitHub Desktop.
<div class="correspondent__stories" <?= $this->next ?>>
<? foreach($this->stories as $story): ?>
<h2><?= $story['headline'] ?></h2>
<? endforeach; ?>
</div>
<?
// ...
$this->next = $this->getNext();
private function getNext()
{
return $this->stories->hasNextPageLink() ? sprintf('data-next="%s"', $this->stories->getNextPageLink()) : '';
}
// ...
?>
@simonyeldon
Copy link

if $story is an object.....

class Story {
    ....
    public function __toString()
    {
        return $this->headline;
    }
}

then it can be

    <? foreach($this->stories as $story): ?>
        <h2><?= $story ?></h2>
    <? endforeach; ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment