'.page_title().'';
$content .= Render\debug_db_info();
if ($GLOBALS['state']['user-state-changed'] ?? false) {
$content .= Render\right_nav();
@@ -65,8 +64,9 @@ exit;
* Just spit out a blank exploring page. Exploring without a GET string is normally when they first log in, or when
* they've just finished fighting.
*/
-function doexplore()
+function explore()
{
+ page_title('Exploring');
return <<
You are exploring the map, and nothing has happened. Continue exploring using the direction buttons or the Travel To menus.
diff --git a/src/actions/towns.php b/src/actions/towns.php
index 39e79a4..4b1f6b8 100644
--- a/src/actions/towns.php
+++ b/src/actions/towns.php
@@ -73,7 +73,7 @@ function town()
HTML;
}
- if (is_htmx()) htmx_update_page_title($townrow['name']);
+ page_title($townrow['name']);
return render('towns', ['town' => $townrow]);
}
@@ -86,7 +86,7 @@ function inn()
if ($town === false) { exit('Cheat attempt detected.
Get a life, loser.'); }
$htmx = is_htmx();
- if ($htmx) htmx_update_page_title($town['name'] . ' Inn');
+ page_title($town['name'] . ' Inn');
if (user()->gold < $town['innprice']) {
$page = << Get a life, loser.'); }
$htmx = is_htmx();
- if ($htmx) htmx_update_page_title($town['name'] . ' Shop');
+ page_title($town['name'] . ' Shop');
$page = <<
diff --git a/src/lib.php b/src/lib.php
index 5468dde..19031b3 100644
--- a/src/lib.php
+++ b/src/lib.php
@@ -142,7 +142,6 @@ function display($content, $title, bool $topnav = true, bool $leftnav = true, bo
return render('layouts/primary', [
"dkgamename" => $controlrow["gamename"],
- "title" => $title,
"content" => $content,
"game_skin" => $game_skin,
"leftnav" => $leftnav ? render('leftnav', ['town_list' => $town_list_html, 'current_town' => $current_town]) : '',
@@ -598,8 +597,11 @@ function is_htmx(): bool
}
/**
- * Update the page title using HTMX.
+ * Get the current page title per updates. Optionally set a new title.
*/
-function htmx_update_page_title(string $new_title) {
- header('HX-Trigger: ' . json_encode(['updateTitle' => ['title' => $new_title]]));
+function page_title(string $new_title = ''): string
+{
+ global $controlrow;
+ if ($new_title) return $GLOBALS['state']['new-page-title'] = $new_title;
+ return $GLOBALS['state']['new-page-title'] ?? $controlrow['gamename'];
}
diff --git a/templates/layouts/primary.php b/templates/layouts/primary.php
index 6f82d9e..9778832 100644
--- a/templates/layouts/primary.php
+++ b/templates/layouts/primary.php
@@ -3,7 +3,7 @@
- = $title ?>
+ = page_title() ?>
@@ -23,7 +23,7 @@