Removing posts

This commit is contained in:
Diego Najar 2017-05-10 23:21:45 +02:00
parent 5145694752
commit aa9ff9d229
2 changed files with 33 additions and 10 deletions

View File

@ -7,12 +7,10 @@ Database structure
{ {
"videos": { "videos": {
"name": "Videos", "name": "Videos",
"posts": [ "first-post", "bull-terrier" ],
"pages": [ "my-page", "second-page" ] "pages": [ "my-page", "second-page" ]
}, },
"pets": { "pets": {
"name": "Pets", "name": "Pets",
"posts": [ "second-post", "bull-terrier" ],
"pages": [ "cats-and-dogs" ] "pages": [ "cats-and-dogs" ]
} }
} }

View File

@ -52,7 +52,6 @@ function buildPage($key)
return $page; return $page;
} }
function reindexCategories() function reindexCategories()
{ {
global $dbPages; global $dbPages;
@ -81,26 +80,52 @@ function reindexTags()
return true; return true;
} }
function buildPagesForAdmin($pageNumber) function buildPagesForAdmin()
{ {
return buildPagesFor('admin', $pageNumber); return buildPagesFor('admin');
} }
function buildPagesForHome($pageNumber) function buildPagesForHome()
{ {
return buildPagesFor('home', $pageNumber); return buildPagesFor('home');
} }
function buildPagesFor($for, $pageNumber) function buildPagesByCategory($categoryKey)
{
return buildPagesFor('category', $categoryKey, false);
}
function buildPagesByTag($tagKey)
{
return buildPagesFor('tag', false, $tagKey);
}
function buildPagesFor($for, $categoryKey=false, $tagKey=false)
{ {
global $dbPages; global $dbPages;
global $dbCategories;
global $Site; global $Site;
// Get the page number from URL
$pageNumber = $Url->pageNumber();
if($for=='admin') { if($for=='admin') {
$list = $dbPages->getList($pageNumber, ITEMS_PER_PAGE_ADMIN, false); $onlyPublished = false;
$amountOfItems = ITEMS_PER_PAGE_ADMIN;
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
} }
elseif($for=='home') { elseif($for=='home') {
$list = $dbPages->getList($pageNumber, $Site->postsPerPage(), true); $onlyPublished = true;
$amountOfItems = $Site->postsPerPage();
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
}
elseif($for=='category') {
$amountOfItems = $Site->postsPerPage();
$list = $dbCategories->getList($categoryKey, $pageNumber, $amountOfItems);
}
elseif($for=='tag') {
$amountOfItems = $Site->postsPerPage();
$list = $dbTags->getList($tagKey, $pageNumber, $amountOfItems);
} }
// There are not items for the page number then set the page notfound // There are not items for the page number then set the page notfound