Site Builder
Editing:
modules-abou2t.php
writable 0666
<?php /************************************************************************** * ABOUT MODULE – v2 “identity strip” * ---------------------------------------------------------------------- * Expected env: * • $profile (array) already set – or – * • ../../profile.json in the same folder as the page using this module **************************************************************************/ /* 1) Load profile only if caller hasn’t supplied it */ if (!isset($profile) || !is_array($profile)) { $json = dirname(__DIR__, 2) . '/profile.json'; $profile = is_readable($json) ? json_decode(file_get_contents($json), true) : []; } /* 2) Convenience vars */ $name = $profile['display_name'] ?? $profile['handle'] ?? 'Profile'; $handle = ltrim($profile['handle'] ?? '', '@'); $descr = trim($profile['description'] ?? ''); $website = $profile['website'] ?? ''; $phone = $profile['phone'] ?? ''; /* location lines */ $addr1 = trim(($profile['address'] ?? '') . ' ' . ($profile['address_2'] ?? '')); $city = $profile['city'] ?? ''; $st = $profile['state'] ?? ''; $zip = $profile['zip'] ?? ''; $loc = trim("$city, $st $zip", ' ,'); /* format phone to (727) 610‑1188 */ if ($phone) { $digits = preg_replace('/\D/', '', $phone); if (strlen($digits) === 10) { $phoneFmt = '('.substr($digits,0,3).') '.substr($digits,3,3).'-'.substr($digits,6); } else { $phoneFmt = $phone; } } /* nothing to show? */ if ($descr === '' && !$website && !$phone && !$loc) { return; } /* ------------------------------------------------------------- */ ?> <!-- ======== ABOUT SECTION ======== --> <section class="bd-about"> <?php if ($descr): ?> <h2>About <?= htmlspecialchars($name) ?></h2> <p><?= nl2br(htmlspecialchars($descr)) ?></p> <?php endif; ?> <div class="bd-idstrip"> <?php if ($handle): ?> <div class="item"> <i class="fas fa-user"></i> <span>@<?= htmlspecialchars($handle) ?></span> </div> <?php endif; ?> <?php if ($website): ?> <div class="item"> <i class="fas fa-globe"></i> <a href="<?= htmlspecialchars($website) ?>" target="_blank" rel="noopener"> <?= preg_replace('#^https?://#','', htmlspecialchars($website)) ?> </a> </div> <?php endif; ?> <?php if ($phone): ?> <div class="item"> <i class="fas fa-phone"></i> <a href="tel:<?= htmlspecialchars($digits ?? $phone) ?>"> <?= htmlspecialchars($phoneFmt) ?> </a> </div> <?php endif; ?> <?php if ($loc || $addr1): ?> <div class="item"> <i class="fas fa-map-marker-alt"></i> <span> <?= htmlspecialchars($addr1 ?: $loc) ?> </span> </div> <?php endif; ?> </div> </section> <style> /* Load once */ .bd-about{padding:1.6rem 0;border-bottom:1px solid #e4e9f3;font-family:system-ui,Arial,sans-serif} .bd-about h2{margin:.1em 0 .75em;font-size:1.4rem;font-weight:700;color:#102a66} .bd-about p{margin:0 0 1.3rem;font-size:1.06rem;line-height:1.55;color:#333} .bd-idstrip{display:flex;flex-wrap:wrap;gap:.9em 1.4em} .bd-idstrip .item{display:flex;align-items:center;gap:.46em;font-size:.96rem;color:#333} .bd-idstrip .item i{color:#0066ff;font-size:1.05rem} .bd-idstrip a{color:#0066ff;text-decoration:none} .bd-idstrip a:hover{text-decoration:underline} @media(max-width:480px){ .bd-idstrip{flex-direction:column;align-items:flex-start} } </style> <?php /* Optional: load FA 5.15 icons if host page hasn’t yet */ static $faLoaded = false; if (!$faLoaded){ echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" media="all">'; $faLoaded = true; } ?>
Save changes
Create folder
writable 0777
Create
Cancel