本文整理汇总了PHP中Parse::frontMatter方法的典型用法代码示例。如果您正苦于以下问题:PHP Parse::frontMatter方法的具体用法?PHP Parse::frontMatter怎么用?PHP Parse::frontMatter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse
的用法示例。
在下文中一共展示了Parse::frontMatter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _render_layout
/**
* _render_layout
* Renders the page
*
* @param string $_html HTML of the template to use
* @param string $template_type Content type of the template
* @return string
*/
public function _render_layout($_html, $template_type = 'html')
{
if (self::$_layout) {
$this->data['layout_content'] = $_html;
if ($template_type != 'html' or self::$_control_panel) {
extract($this->data);
ob_start();
require self::$_layout . ".php";
$html = ob_get_clean();
} else {
if (!File::exists(self::$_layout . ".html")) {
Log::fatal("Can't find the specified theme.", 'core', 'template');
return '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">We can\'t find your theme files. Please check your settings.';
}
$this->appendNewData($this->data);
// Fetch layout and parse any front matter
$layout = Parse::frontMatter(File::get(self::$_layout . '.html'), false);
$html = Parse::template($layout['content'], Statamic_View::$_dataStore, array($this, 'callback'));
$html = Lex\Parser::injectNoparse($html);
}
} else {
$html = $_html;
}
// post-render hook
$html = \Hook::run('_render', 'after', 'replace', $html, $html);
return $html;
}
示例2: control_panel__form_content
/**
* Swap out form content if necessary
*
* @param array $data The form data that is going to be used unless changed
* @return array
*/
public function control_panel__form_content($data)
{
// master switch for revisions
if (!$this->core->isEnabled()) {
return $data;
}
if ($this->core->isRevisionSelected()) {
$revision = Request::get('revision');
$file = Request::get('path');
$this->core->normalizePath($file);
// does this revision exist?
if ($this->core->isRevision($file, $revision)) {
$this->blink->set('is_revision', true);
$this->blink->set('is_latest_revision', $this->core->isLatestRevision($file, $revision));
$this->blink->set('current_revision', $revision);
// load revision content
$raw_file = $this->core->getRevision($file, $revision);
$raw_data = Parse::frontMatter($raw_file);
$data = $raw_data['data'] + array('content' => $raw_data['content']);
}
} else {
// save first revision is none are set
$file = $this->core->getPath();
if (!$this->core->hasRevisions($file)) {
$this->core->saveFirstRevision($file);
}
}
return $data;
}