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 '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( echo Bootstrap::formInputText(array(
'name' => 'uriAuthor', 'name' => 'uriAuthor',
'label' => $L->g('Authors'), 'label' => $L->g('Authors'),

View file

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

View file

@ -126,10 +126,20 @@ function buildPagesByArchive()
return buildPagesFor('archive', false, false, false, $archiveKey); 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! // 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 // Generate the global variables $content / $content, defined on 69.pages.php
// This function is use for buildPagesForHome(), buildPagesByCategory(), buildPagesByTag() // 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 $pages;
global $categories; global $categories;
@ -138,6 +148,7 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey =
global $url; global $url;
global $authors; global $authors;
global $archives; global $archives;
global $kinds;
// Get the page number from URL // Get the page number from URL
$pageNumber = $url->pageNumber(); $pageNumber = $url->pageNumber();
@ -164,6 +175,9 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey =
} elseif ($for == 'archive') { } elseif ($for == 'archive') {
$numberOfItems = $site->itemsPerPage(); $numberOfItems = $site->itemsPerPage();
$list = $archives->getList($archiveKey, $pageNumber, $numberOfItems); $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... // 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); $db = $pages->getDB($onlyKeys=false);
foreach ($db as $pageKey=>$pageFields) { foreach ($db as $pageKey=>$pageFields) {
if ($pageFields['state'] == "published" && isset($pageFields['kinds']) && $pageFields !== '') { if ($pageFields['type'] == "published" && isset($pageFields['kind']) && $pageFields !== '') {
$kind = $pageFields['kind']; $kind = $pageFields['kind'];
// Index by years // Index by years

View file

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