Allow static pages to have subpages

This commit is contained in:
Diego Najar 2019-09-08 10:35:21 +02:00
parent 7aba5362c6
commit 3dd31b9d11
2 changed files with 22 additions and 9 deletions

View File

@ -77,7 +77,7 @@ function table($type) {
foreach ($list as $pageKey) {
try {
$page = new Page($pageKey);
if (!$page->isChild() || $type!='published') {
if (!$page->isChild()) {
echo '<tr>
<td>
<div>
@ -106,7 +106,7 @@ function table($type) {
echo '</tr>';
foreach ($page->children() as $child) {
if ($child->published()) {
//if ($child->published()) {
echo '<tr>
<td class="child">
<div>
@ -133,7 +133,7 @@ function table($type) {
echo '</td>';
echo '</tr>';
}
//}
}
}
} catch (Exception $e) {

View File

@ -2,7 +2,8 @@
header('Content-Type: application/json');
/*
| Returns a list of pages are parent and match with the string in them titles
| Returns a list of parent pages and the title contains the query string
| The returned list have published, sticky and statics pages
|
| @_POST['query'] string The string to search in the title of the pages
|
@ -19,11 +20,23 @@ if ($query===false) {
}
$tmp = array();
$parents = buildParentPages();
foreach ($parents as $parent) {
$lowerTitle = Text::lowercase($parent->title());
if (Text::stringContains($lowerTitle, $query)) {
$tmp[$parent->title()] = $parent->key();
$pagesKey = $pages->getDB();
foreach ($pagesKey as $pageKey) {
try {
$page = new Page($pageKey);
// Check if the page is available to be parent
if ($page->isParent()) {
// Check page status
if ($page->published() || $page->sticky() || $page->isStatic()) {
// Check if the query contains in the title
$lowerTitle = Text::lowercase($page->title());
if (Text::stringContains($lowerTitle, $query)) {
$tmp[$page->title()] = $page->key();
}
}
}
} catch (Exception $e) {
// continue
}
}