Predefined pages, such as homepage and page not found

This commit is contained in:
Diego Najar 2017-09-04 19:09:37 +02:00
parent 6b15fcb427
commit 8e9578dcc4
6 changed files with 33 additions and 7 deletions

View File

@ -94,4 +94,6 @@ foreach($allPublishedPages as $key=>$page) {
} else {
$homepageOptions[$key] = $page->title();
}
ksort($homepageOptions);
}

View File

@ -28,11 +28,11 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'tip'=>$L->g('the-url-of-your-site')
));
HTML::legend(array('value'=>$L->g('Home page')));
HTML::legend(array('value'=>$L->g('Predefined pages')));
HTML::formSelect(array(
'name'=>'homepage',
'label'=>$L->g('Default home page'),
'label'=>$L->g('Home page'),
'options'=>$homepageOptions,
'selected'=>$Site->homepage(),
'class'=>'uk-width-1-3 uk-form-medium',
@ -40,6 +40,16 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'addEmptySpace'=>true
));
HTML::formSelect(array(
'name'=>'pageNotFound',
'label'=>$L->g('Page not found'),
'options'=>$homepageOptions,
'selected'=>$Site->pageNotFound(),
'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>'',
'addEmptySpace'=>true
));
HTML::legend(array('value'=>$L->g('Website or Blog')));
HTML::formSelect(array(

View File

@ -134,9 +134,9 @@ elseif ($Url->whereAmI()==='admin') {
// Set page 404 not found
if ($Url->notFound()) {
$page = $Page = buildPage('error');
$page = buildPage( $Site->pageNotFound() );
if ($page===false) {
$page = buildErrorPage();
}
$pages[0] = $page;
$pages[0] = $Page = $page;
}

View File

@ -14,6 +14,7 @@ class dbSite extends dbJSON
'theme'=> array('inFile'=>false, 'value'=>'pure'),
'adminTheme'=> array('inFile'=>false, 'value'=>'default'),
'homepage'=> array('inFile'=>false, 'value'=>''),
'pageNotFound'=> array('inFile'=>false, 'value'=>''),
'uriPage'=> array('inFile'=>false, 'value'=>'/'),
'uriTag'=> array('inFile'=>false, 'value'=>'/tag/'),
'uriCategory'=> array('inFile'=>false, 'value'=>'/category/'),
@ -290,6 +291,16 @@ class dbSite extends dbJSON
return $homepage;
}
// Returns the page defined for "Page not found", FALSE if not defined
public function pageNotFound()
{
$pageNotFound = $this->getField('pageNotFound');
if( empty($pageNotFound) ) {
return false;
}
return $pageNotFound;
}
// Set the locale, returns TRUE is success, FALSE otherwise
public function setLocale($locale)
{

View File

@ -72,8 +72,8 @@ function buildErrorPage() {
global $Language;
$page = new Page(false);
$page->setField('title', 'Page not found');
$page->setField('content', $Language->get('installer-page-error-content'));
$page->setField('title', $Language->get('page-not-found'));
$page->setField('content', $Language->get('page-not-found-content'));
return $page;
}

View File

@ -147,5 +147,8 @@
"there-are-no-draft-pages": "There are no draft pages",
"order-content-by": "Order content By",
"edit-or-delete-content-from-your-site": "Edit or delete content from your site",
"order-the-content-by-position-to-build-a-website": "Order the content by position to build a Website or order the content by date to build a Blog."
"order-the-content-by-position-to-build-a-website": "Order the content by position to build a Website or order the content by date to build a Blog.",
"page-not-found-content": "Hey! look like the page doesn't exist.",
"page-not-found": "Page not found",
"predefined-pages": "Predefined pages"
}