Siteβ―Builder
Editing:
indessssssssssssssssssx.php
writable 0666
<?php /************************************************************************** * BUSINESS PROFILE INDEX β masonry edition (v3, 2025β07βXX) * ---------------------------------------------------------------------- * β’ First card = Business Card (from profile.json only) * β’ Masonry grid using CSSΒ Columns (widens gaps on wide screens) * β’ Skips modules that render no content (no more blank white boxes) * β’ Requires PHPΒ 8.1+ **************************************************************************/ declare(strict_types=1); require_once $_SERVER['DOCUMENT_ROOT'].'/pages/lib/helpers.php'; /* βββ load profile βββββββββββββββββββββββββββββββββββββββββββββββββββ */ $profile = get_profile(); /* βββ handy escapers & formatters ββββββββββββββββββββββββββββββββββββ */ function h(string $s): string {return htmlspecialchars($s, ENT_QUOTES, 'UTF-8');} function state_slug(string $st): string {return strtoupper(trim($st));} function city_slug(string $c): string {return strtolower(str_replace(' ', '-', $c));} 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; } /* βββ pull fields from profile βββββββββββββββββββββββββββββββββββββββ */ $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 = state_slug($state); $cityslug = city_slug($city); /* βββ meta tags ββββββββββββββββββββββββββββββββββββββββββββββββββββββ */ $metaTitle = "$name in $city, $state | BestDealOn"; $metaDesc = $desc ?: ($slogan ?: $name); $canonical = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; /* βββ modules list βββββββββββββββββββββββββββββββββββββββββββββββββββ */ $rootDir = $_SERVER['DOCUMENT_ROOT']; $modulesDir = "$rootDir/pages/modules"; $globalCfg = "$modulesDir/modules.json"; $localCfg = __DIR__.'/config.json'; $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 overrides 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($canonical)?>"> <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);} /* canvas colour */ /* βββ thin header βββββββββββββββββββββββββββββββββββββββββββ */ .top-bar{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:.45rem;padding:.55rem 1rem;background:#eee;text-align:center} .logo{font-weight:900;letter-spacing:-.5px;color:var(--link);text-decoration:none} .breadcrumb a{color:var(--link);text-decoration:none} .breadcrumb span{margin:0 .25rem} /* βββ business card ββββββββββββββββββββββββββββββββββββββββ */ .biz-card{max-width:680px;margin:2rem auto;background:var(--card-bg);border-radius:20px;box-shadow:var(--card-shadow);padding:2rem 1.4rem;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}} /* βββ masonry grid via CSSΒ Columns βββββββββββββββββββββββββ */ .modules{column-width:340px;column-gap:1.6rem;row-gap:1.6rem;max-width:960px;margin:0 auto 3rem;padding:0 1rem} @media(min-width:1000px){.modules{column-gap:2.2rem}} /* wider gutters on desktop */ /* card wrapper used by modules */ .mod-card{display:inline-block;width:100%;margin:0 0 1.6rem;background:var(--card-bg);border-radius:20px;box-shadow:var(--card-shadow);padding:1.6rem;break-inside:avoid} </style> </head><body> <!-- βββ 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" rel="noopener"><?=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 masonry βββββββββββββββββββββββββββββββββββ --> <main class="modules"> <?php foreach($modules as $mod){ $abs = $modulesDir.'/'.$mod['relative_path']; if(!is_file($abs)) continue; /* buffer include β skip card if module outputs nothing */ ob_start(); try { include $abs; } catch(Throwable $e){ error_log($e->getMessage()); } $html = trim(ob_get_clean()); if($html==='') continue; // module decided to hide itself echo "<section class='mod-card'>\n$html\n</section>\n"; } ?> </main> </body></html>
Save changes
Create folder
writable 0777
Create
Cancel