Add post kind uri handling

This commit is contained in:
Kazhnuz 2025-06-26 12:42:53 +02:00
parent a92d77ccdf
commit d984facf15
5 changed files with 33 additions and 4 deletions

View file

@ -306,6 +306,15 @@ echo Bootstrap::formInputHidden(array(
'tip' => DOMAIN_ARCHIVES
));
echo Bootstrap::formInputText(array(
'name' => 'uriKind',
'label' => $L->g('Post Kind'),
'value' => $site->uriFilters('kind'),
'class' => '',
'placeholder' => '',
'tip' => DOMAIN_KINDS
));
echo Bootstrap::formInputText(array(
'name' => 'uriAuthor',
'label' => $L->g('Authors'),

View file

@ -75,10 +75,14 @@ elseif ($url->whereAmI()==='category') {
elseif ($url->whereAmI()==='author') {
$content = buildPagesByAuthor();
}
// Build content by author
// Build content by archive
elseif ($url->whereAmI()==='archive') {
$content = buildPagesByArchive();
}
// Build content by archive
elseif ($url->whereAmI()==='kind') {
$content = buildPagesByKind();
}
// Build content for the homepage
elseif ( ($url->whereAmI()==='home') || ($url->whereAmI()==='blog') ) {
$content = buildPagesForHome();

View file

@ -126,10 +126,20 @@ function buildPagesByArchive()
return buildPagesFor('archive', false, false, false, $archiveKey);
}
// This function is only used from the rule 69.pages.php, DO NOT use this function!
function buildPagesByKind()
{
global $url;
$kindKey = $url->slug();
return buildPagesFor('kind', false, false, false, false, $kindKey);
}
// This function is only used from the rule 69.pages.php, DO NOT use this function!
// Generate the global variables $content / $content, defined on 69.pages.php
// This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag()
function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = false, $archiveKey = false)
function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = false, $archiveKey = false, $kindKey = false)
{
global $pages;
global $categories;
@ -138,6 +148,7 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey =
global $url;
global $authors;
global $archives;
global $kinds;
// Get the page number from URL
$pageNumber = $url->pageNumber();
@ -164,6 +175,9 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey =
} elseif ($for == 'archive') {
$numberOfItems = $site->itemsPerPage();
$list = $archives->getList($archiveKey, $pageNumber, $numberOfItems);
} elseif ($for == 'kind') {
$numberOfItems = $site->itemsPerPage();
$list = $kinds->getList($kindKey, $pageNumber, $numberOfItems);
}
// There are not items, invalid tag, invalid category, out of range, etc...

View file

@ -27,7 +27,7 @@ class Kinds extends dbList {
$db = $pages->getDB($onlyKeys=false);
foreach ($db as $pageKey=>$pageFields) {
if ($pageFields['state'] == "published" && isset($pageFields['kinds']) && $pageFields !== '') {
if ($pageFields['type'] == "published" && isset($pageFields['kind']) && $pageFields !== '') {
$kind = $pageFields['kind'];
// Index by years

View file

@ -21,6 +21,7 @@ class Site extends dbJSON
'uriBlog' => '/blog/',
'uriAuthor' => '/author/',
'uriArchive' => '/archive/',
'uriKind' => '/kind/',
'url' => '',
'emailFrom' => '',
'dateFormat' => 'F j, Y',
@ -104,7 +105,8 @@ class Site extends dbJSON
$filters['tag'] = $this->getField('uriTag');
$filters['category'] = $this->getField('uriCategory');
$filters['author'] = $this->getField('uriAuthor');
$filters['archive'] = $this->getField(field: 'uriArchive');
$filters['archive'] = $this->getField('uriArchive');
$filters['kind'] = $this->getField('uriKind');
if ($this->getField('uriBlog')) {
$filters['blog'] = $this->getField('uriBlog');