feat(site): root opens the main gym; other gyms as navbar buttons
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aa55d44406
commit
716eec9f6d
4 files changed
+45
-4
No files matched your search
@@ -78,7 +78,7 @@ Sistema → Auditoria (`platform.php?tool=audit`).
|
||||
Since 2026-09-25, one install serves several physical gyms: the `gyms` table, one URL
|
||||
folder per gym (`/3070/`, `/<postal-code>/`), content rows carry `gym_id`, and the
|
||||
backoffice has an "a editar" gym switcher (`admin_gym_id()` /
|
||||
`admin_gym()` in `config/functions_gyms.php`). `/` and `/home` 301 to the default gym.
|
||||
`admin_gym()` in `config/functions_gyms.php`). `/` and `/home` 301 to the default gym (`is_default`); the other published gyms appear as highlighted buttons (`.gym-switch-btn`) at the right end of the public navbar (`site/includes/navbar.php`). `site/gym_chooser.php` is no longer used.
|
||||
An unpublished gym 404s publicly but previews for staff.
|
||||
|
||||
## platform-tools
|
||||
|
||||
@@ -408,6 +408,29 @@ section[id] {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
/* ── Other-gym button (right end of the navbar) ────────────────────────────── */
|
||||
.gym-switch-btn {
|
||||
display: inline-block;
|
||||
background: var(--fitme-accent);
|
||||
color: var(--fitme-dark);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .5px;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
border: 2px solid var(--fitme-accent);
|
||||
border-radius: var(--fitme-radius);
|
||||
padding: 6px 16px;
|
||||
transition: background-color var(--fitme-transition), color var(--fitme-transition);
|
||||
}
|
||||
|
||||
.gym-switch-btn:hover,
|
||||
.gym-switch-btn:focus-visible {
|
||||
background: var(--fitme-dark);
|
||||
border-color: var(--fitme-dark);
|
||||
color: var(--fitme-accent);
|
||||
}
|
||||
|
||||
/* ── Sticky Navbar ─────────────────────────────────────────────────────────── */
|
||||
.navbar-toggler {
|
||||
min-width: 44px;
|
||||
|
||||
@@ -47,6 +47,22 @@ $logo_dims = svg_img_dims_attr(dirname(__DIR__, 2) . '/' . $logo_rel);
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php
|
||||
// Other published gyms: the main gym opens first, the rest are
|
||||
// highlighted buttons at the right end of the bar.
|
||||
$other_gyms = [];
|
||||
if (!empty($GLOBALS['pdo'])) {
|
||||
foreach (db_gyms_published($GLOBALS['pdo']) as $g) {
|
||||
if ((int) $g['id'] !== (int) current_gym()['id']) $other_gyms[] = $g;
|
||||
}
|
||||
}
|
||||
if ($other_gyms): ?>
|
||||
<div class="gym-switch d-flex flex-wrap gap-2 ms-lg-auto py-2 py-lg-0 pe-lg-3">
|
||||
<?php foreach ($other_gyms as $g): ?>
|
||||
<a class="gym-switch-btn" href="<?= htmlspecialchars(gym_url($g)) ?>"><?= htmlspecialchars($g['name']) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
+5
-3
@@ -5,13 +5,15 @@ $current_uri_2 = '';
|
||||
|
||||
// No gym in the URL (/, /home, old links): send people to a gym page. With a
|
||||
// single published gym that is a 301 to it (query string kept, e.g.
|
||||
// ?agendar=ok); with more, the gym chooser.
|
||||
// ?agendar=ok); with more, the main (default) gym — the others are reached
|
||||
// from the navbar's «Ginásios» menu.
|
||||
if (($_GET['gym'] ?? '') === '') {
|
||||
require_once __DIR__ . '/../config/db.php';
|
||||
require_once __DIR__ . '/../config/functions.php';
|
||||
$published = db_gyms_published($pdo);
|
||||
if (count($published) > 1) { require __DIR__ . '/gym_chooser.php'; exit; }
|
||||
$to = $published[0] ?? db_gyms_default($pdo) ?? gym_fallback();
|
||||
$main = null;
|
||||
foreach ($published as $g) { if ((int) ($g['is_default'] ?? 0) === 1) { $main = $g; break; } }
|
||||
$to = $main ?? $published[0] ?? db_gyms_default($pdo) ?? gym_fallback();
|
||||
$qs = $_SERVER['QUERY_STRING'] ?? '';
|
||||
header('Location: ' . gym_url($to) . ($qs !== '' ? '?' . $qs : ''), true, 301);
|
||||
exit;
|
||||
|
||||
Reference in new issue
Block a user