本文整理汇总了PHP中Frontend\Core\Engine\Model::getPageRevision方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::getPageRevision方法的具体用法?PHP Model::getPageRevision怎么用?PHP Model::getPageRevision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frontend\Core\Engine\Model
的用法示例。
在下文中一共展示了Model::getPageRevision方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPageContent
/**
* Get page content
*/
protected function getPageContent()
{
// load revision
if ($this->URL->getParameter('page_revision', 'int') != 0) {
// get data
$this->record = Model::getPageRevision($this->URL->getParameter('page_revision', 'int'));
// add no-index to meta-custom, so the draft won't get accidentally indexed
$this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
} else {
// get page record
$this->record = (array) Model::getPage($this->pageId);
}
// empty record (pageId doesn't exists, hope this line is never used)
if (empty($this->record) && $this->pageId != 404) {
\SpoonHTTP::redirect(Navigation::getURL(404), 404);
}
// init var
$redirect = true;
// loop blocks, if all are empty we should redirect to the first child
foreach ($this->record['positions'] as $blocks) {
// loop blocks in position
foreach ($blocks as $block) {
// HTML provided?
if ($block['html'] != '') {
$redirect = false;
}
// an decent extra provided?
if ($block['extra_type'] == 'block') {
$redirect = false;
}
// a widget provided
if ($block['extra_type'] == 'widget') {
$redirect = false;
}
}
}
// should we redirect?
if ($redirect) {
// get first child
$firstChildId = Navigation::getFirstChildId($this->record['id']);
// validate the child
if ($firstChildId !== false) {
// build URL
$URL = Navigation::getURL($firstChildId);
// redirect
\SpoonHTTP::redirect($URL, 301);
}
}
}
示例2: getPageContent
/**
* Get page content
*
* @param $pageId
*
* @return array
* @throws RedirectException
*/
protected function getPageContent($pageId)
{
// load revision
if ($this->URL->getParameter('page_revision', 'int') != 0) {
// get data
$record = Model::getPageRevision($this->URL->getParameter('page_revision', 'int'));
// add no-index to meta-custom, so the draft won't get accidentally indexed
$this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
} else {
// get page record
$record = (array) Model::getPage($pageId);
}
if (empty($record)) {
return array();
}
// init var
$redirect = true;
// loop blocks, if all are empty we should redirect to the first child
foreach ($record['positions'] as $blocks) {
// loop blocks in position
foreach ($blocks as $block) {
// HTML provided?
if ($block['html'] != '') {
$redirect = false;
}
// an decent extra provided?
if ($block['extra_type'] == 'block') {
$redirect = false;
}
// a widget provided
if ($block['extra_type'] == 'widget') {
$redirect = false;
}
}
}
// should we redirect?
if ($redirect) {
// get first child
$firstChildId = Navigation::getFirstChildId($record['id']);
// validate the child
if ($firstChildId !== false) {
// build URL
$url = Navigation::getURL($firstChildId);
// redirect
throw new RedirectException('Redirect', new RedirectResponse($url, 301));
}
}
return $record;
}