Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Last active August 29, 2015 14:12
Show Gist options
  • Save bastianallgeier/a4c97bae348d72b16e42 to your computer and use it in GitHub Desktop.
Save bastianallgeier/a4c97bae348d72b16e42 to your computer and use it in GitHub Desktop.
<?php
/**
* This is a preview for an upcoming Kirby feature.
*
* This class extends all pages with the template
* project.php and makes it possible to add custom features
* and methods to the $page object, which can then be
* used everywhere throughout Kirby.
*
* All models will go into site/models and just have to have
* the same filename as the template and a class name which
* follows the pattern {templatename}Page.
*/
class ProjectPage extends Page {
public function excerpt($length = 80) {
return $this->text()->excerpt($length);
}
public function images() {
return parent::images()->sortBy('sort', 'asc');
}
public function cover() {
return $this->images()->first();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment