✨ (themes): add an API to get a title page
This commit is contained in:
parent
b9a02584dc
commit
c2ed24a7c7
3 changed files with 55 additions and 1 deletions
|
@ -23,7 +23,8 @@ class Authors extends dbList {
|
|||
if (isset($authorsIndex[$authorName])) {
|
||||
array_push($authorsIndex[$authorName]['list'], $pageKey);
|
||||
} else {
|
||||
$authorsIndex[$authorName]['name'] = $authorName;
|
||||
$user = new User($pageFields['username']);
|
||||
$authorsIndex[$authorName]['name'] = $user->displayName();
|
||||
$authorsIndex[$authorName]['list'] = array($pageKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,55 @@ class Theme
|
|||
return DOMAIN_ADMIN;
|
||||
}
|
||||
|
||||
public static function locationTitle()
|
||||
{
|
||||
global $url;
|
||||
global $site;
|
||||
global $tags;
|
||||
global $archives;
|
||||
global $authors;
|
||||
global $categories;
|
||||
global $WHERE_AM_I;
|
||||
global $page;
|
||||
|
||||
if ($WHERE_AM_I == 'page') {
|
||||
return $page->title();
|
||||
} elseif ($WHERE_AM_I == 'tag') {
|
||||
try {
|
||||
$tagKey = $url->slug();
|
||||
$tag = new Tag($tagKey);
|
||||
return $tag->name();
|
||||
} catch (Exception $e) {
|
||||
// Tag doesn't exist
|
||||
}
|
||||
} elseif ($WHERE_AM_I == 'category') {
|
||||
try {
|
||||
$categoryKey = $url->slug();
|
||||
$category = new Category($categoryKey);
|
||||
return $category->name();
|
||||
} catch (Exception $e) {
|
||||
// Category doesn't exist
|
||||
}
|
||||
} elseif ($WHERE_AM_I == 'archive') {
|
||||
try {
|
||||
$archiveKey = $url->slug();
|
||||
return Date::prettyArchiveDate($archiveKey);
|
||||
} catch (Exception $e) {
|
||||
// Archive doesn't exist
|
||||
}
|
||||
} elseif ($WHERE_AM_I == 'author') {
|
||||
try {
|
||||
$authorKey = $url->slug();
|
||||
$user = new User($authorKey);
|
||||
return $user->displayName();
|
||||
} catch (Exception $e) {
|
||||
// Author doesn't exist
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function metaTags($tag)
|
||||
{
|
||||
if ($tag == 'title') {
|
||||
|
|
|
@ -47,6 +47,10 @@
|
|||
<?php endif ?>
|
||||
<!-- End Search input -->
|
||||
|
||||
<?php if (Theme::locationTitle()): ?>
|
||||
<h2><?php echo Theme::locationTitle(); ?></h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Content not available -->
|
||||
<?php if (empty($content)) : ?>
|
||||
<div class="text-center p-4">
|
||||
|
|
Loading…
Reference in a new issue