Skip to content

Commit d4e1744

Browse files
committed
Merge branch 'develop' of https://github.com/getgrav/grav into develop
# By Sommerregen # Via Andy Miller (1) and Sommerregen (1) * 'develop' of https://github.com/getgrav/grav: Added summary option
2 parents eb4eafd + 89ebf2b commit d4e1744

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

system/src/Grav/Common/Page/Page.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -308,26 +308,31 @@ public function summary($size = null)
308308
return $content;
309309
}
310310

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

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

325+
// If the size is zero, return the entire page content
326+
if ($size === 0) {
327+
return $content;
321328
// Return calculated summary based on defaults
322-
if (!is_numeric($size) || ($size < 0)) {
329+
} elseif (!is_numeric($size) || ($size < 0)) {
323330
$size = 300;
324331
}
325332

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

329-
330-
331336
/**
332337
* Gets and Sets the content based on content portion of the .md file
333338
*

0 commit comments

Comments
 (0)