Last active
August 29, 2015 14:12
-
-
Save bastianallgeier/a4c97bae348d72b16e42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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