Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/getgrav/grav into develop
Browse files Browse the repository at this point in the history
# By Sommerregen
# Via Andy Miller (1) and Sommerregen (1)
* 'develop' of https://github.com/getgrav/grav:
  Added summary option
  • Loading branch information
rhukster committed Feb 3, 2015
2 parents eb4eafd + 89ebf2b commit d4e1744
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions system/src/Grav/Common/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,26 +308,31 @@ public function summary($size = null)
return $content;
}

// Return calculated summary based on summary divider's position
if (!$size && isset($this->summary_size)) {
return substr($content, 0, $this->summary_size);
// Get summary size from site config's file
if (is_null($size)) {
$size = $config->get('site.summary.size', null);
}

// Return calculated summary based on setting in site config file
if (is_null($size) && $config->get('site.summary.size')) {
$size = $config->get('site.summary.size');
// Return calculated summary based on summary divider's position
$format = $config->get('site.summary.format', 'short');
// Return entire page content on wrong/ unknown format
if (!in_array($format, array('short', 'long'))) {
return $content;
} elseif (($format === 'short') && isset($this->summary_size)) {
return substr($content, 0, $this->summary_size);
}

// If the size is zero, return the entire page content
if ($size === 0) {
return $content;
// Return calculated summary based on defaults
if (!is_numeric($size) || ($size < 0)) {
} elseif (!is_numeric($size) || ($size < 0)) {
$size = 300;
}

return Utils::truncateHTML($content, $size);
}



/**
* Gets and Sets the content based on content portion of the .md file
*
Expand Down

0 comments on commit d4e1744

Please sign in to comment.