现在可以调用$this->summary,来自动输出文章的第一个段落作为摘要
This commit is contained in:
祁宁 2014-03-11 11:28:08 +08:00
parent 31a59be5e6
commit e3095acfc3

View File

@ -141,6 +141,22 @@ class Widget_Abstract_Contents extends Widget_Abstract
return $this->pluginHandle(__CLASS__)->contentEx($content, $this);
}
/**
* 输出文章的第一行作为摘要
*
* @return string
*/
protected function ___summary()
{
$content = $this->content;
$parts = preg_split("/<\/\s*(?:p|blockquote|q|pre)\s*>/i", $content, 2);
if (!empty($parts)) {
$content = $parts[0] . '</p>';
}
return $content;
}
/**
* 锚点id
*