Siteβ―Builder
Editing:
indegggggggggggggx.php
writable 0666
<?php /************************************************************************** * BUSINESS PROFILE INDEX (v1) β /business/index.php * ---------------------------------------------------------------------- * Reβuses the same module system as the social microsite, but the first * card is a *Business Card* pulled from profile.json (only!). * * β’ Requires PHPΒ 8.1+ * β’ Assumes directory structure: * /business/<slug>/index.php (this file) * /business/<slug>/profile.json (single source of truth) * /pages/modules/* (common modules) * * © 2025Β BestDealOn β free to modify. **************************************************************************/ declare(strict_types=1); require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/lib/helpers.php'; /* ---------- profile + local site config ---------- */ $profile = get_profile(); /* βββ CONFIG βββββββββββββββββββββββββββββββββββββββββββββββ */ $rootDir = $_SERVER['DOCUMENT_ROOT']; $modulesDir= $rootDir . '/pages/modules'; // same modules folder $globalCfg = $modulesDir . '/modules.json'; // master module list $localCfg = __DIR__ . '/config.json'; // perβbusiness overrides /* βββ Helpers ββββββββββββββββββββββββββββββββββββββββββββββ */ function h(string $s): string {return htmlspecialchars($s, ENT_QUOTES, 'UTF-8');} function city_slug(string $city): string {return strtolower(str_replace(' ', '-', $city));} function us_state_slug(string $st): string {return strtoupper(trim($st));} function fmt_phone(string $n): string { $d = preg_replace('/\D/','',$n); return strlen($d)===10 ? sprintf('(%s) %sβ%s', substr($d,0,3), substr($d,3,3), substr($d,6)) : $n; } /* βββ Extract fields ββββββββββββββββββββββββββββββββ */ $name = $profile['display_name'] ?? 'Business'; $slogan = $profile['slogan'] ?? ''; $desc = $profile['description'] ?? ''; $addr = $profile['address'] ?? ''; $city = $profile['city'] ?? ''; $state = $profile['state'] ?? ''; $zip = $profile['zip'] ?? ''; $phone = $profile['phone'] ?? ''; $site = $profile['website'] ?? ''; $slug = $profile['slug'] ?? basename(__DIR__); $country= 'USA'; $stateslug = us_state_slug($state); $cityslug = city_slug($city); /* βββ Meta tags βββββββββββββββββββββββββββββββββββββββββ */ $metaTitle = "$name in $city, $state | BestDealOn"; $metaDesc = $desc ?: ($slogan ?: $name); $url = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; /* βββ Load modules list ββββββββββββββββββββββββββββββ */ $globalMods = is_readable($globalCfg) ? json_decode(file_get_contents($globalCfg), true) : []; $localMods = is_readable($localCfg) ? json_decode(file_get_contents($localCfg) , true) : []; $ordered = []; foreach ($localMods as $m) $ordered[$m['name']] = $m; // local takes precedence foreach ($globalMods as $g) if (!isset($ordered[$g['name']])) $ordered[$g['name']] = $g; $modules = array_filter($ordered, fn($m)=>($m['active']??false)===true); ?> <!doctype html><html lang="en"><head> <meta charset="utf-8"> <title><?=h($metaTitle)?></title> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="description" content="<?=h($metaDesc)?>"> <link rel="canonical" href="<?=h($url)?>"> <style> :root{ --fg:#1b334a;--link:#2357d7;--card-bg:#fff;--card-shadow:0 2px 16px #dde3fa26; font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif; } body{margin:0;background:#f5f8fb;color:var(--fg);} /* Thin header */ .top-bar{display:flex;justify-content:space-between;align-items:center;padding:.55rem 1rem;background:#eee;gap:.4rem;flex-wrap:wrap;text-align:center} .logo{font-weight:900;letter-spacing:-.5px;text-decoration:none;color:var(--link);} nav a{color:var(--link);text-decoration:none} nav span{margin:0 .25rem} /* Business card grid */ .biz-card{background:var(--card-bg);border-radius:20px;box-shadow:var(--card-shadow);padding:2rem 1.4rem;max-width:680px;margin:2rem auto;display:grid;gap:1rem;grid-template-columns:1fr 1fr} .biz-card h1{grid-column:1/-1;font-size:1.7rem;color:#2c61d7;margin:.1em 0} .biz-card .slogan{grid-column:1/-1;color:#2e6eb0;font-style:italic;font-size:1.1rem} .field{display:flex;gap:.6rem} .label{font-weight:600;min-width:95px;color:#23487b} .value{color:#364868} @media(max-width:600px){.biz-card{grid-template-columns:1fr}.field{flex-direction:column;}} /* modules grid */ .modules{display:grid;gap:1.4rem;max-width:960px;margin:0 auto 2.5rem;padding:0 1rem} @media(min-width:750px){.modules{grid-template-columns:repeat(2,1fr)}} </style> </head><body> <!-- Thin header / breadcrumb --> <div class="top-bar"> <a class="logo" href="/">BESTΒ DEALΒ ON</a> <nav class="breadcrumb" aria-label="Breadcrumb"> <a href="/">Index</a><span>/</span> <a href="/geo/<?=h($country)?>/<?=h($stateslug)?>/"><?=h($stateslug)?></a><span>/</span> <?php if($city): ?><a href="/geo/<?=h($country)?>/<?=h($stateslug)?>/<?=h($cityslug)?>/"><?=h($city)?></a><span>/</span><?php endif; ?> <span><?=h($name)?></span> </nav> </div> <!-- Business Info Card --> <section class="biz-card"> <h1><?=h($name)?></h1> <?php if($slogan): ?><div class="slogan"><?=h($slogan)?></div><?php endif; ?> <?php if($addr||$city||$state||$zip): ?> <div class="field"><span class="label">Address:</span><span class="value"> <?php if($addr) echo h($addr).'<br>'; ?> <?=h(trim(($city?$city.', ':'').$state.' '.$zip))?> </span></div> <?php endif; ?> <?php if($phone): ?><div class="field"><span class="label">Phone:</span><span class="value"><b><?=h(fmt_phone($phone))?></b></span></div><?php endif; ?> <?php if($site): ?><div class="field"><span class="label">Website:</span><span class="value"><a href="<?=h($site)?>" target="_blank"><?=h($site)?></a></span></div><?php endif; ?> <?php if($desc): ?><div class="field" style="grid-column:1/-1"><span class="value" style="line-height:1.4;"><?=h($desc)?></span></div><?php endif; ?> </section> <!-- Modules grid --> <main class="modules"> <?php foreach($modules as $mod){ $abs = $modulesDir.'/'.$mod['relative_path']; if(is_file($abs)){ echo "<section class='mod-card' style='background:var(--card-bg);border-radius:20px;box-shadow:var(--card-shadow);padding:1.6rem'>"; try{ include $abs; } catch(Throwable $e){ echo '<p style="color:#c00">Module '.h($mod['name']).' failed.</p>'; } echo '</section>'; } } ?> </main> </body></html>
Save changes
Create folder
writable 0777
Create
Cancel