Site Builder
Editing:
indexrealgood.php
writable 0666
<?php // Load categories (your actual data file, as before) $jsonFile = __DIR__ . '/allcategories.json'; $categories = file_exists($jsonFile) ? json_decode(file_get_contents($jsonFile), true) : []; $country = isset($_GET['country']) ? preg_replace('/[^A-Za-z]/','',$_GET['country']) : 'USA'; $state = isset($_GET['state']) ? preg_replace('/[^A-Za-z]/','',$_GET['state']) : 'FL'; $city = isset($_GET['city']) ? preg_replace('/[^A-Za-z0-9\- ]/','',$_GET['city']) : 'Seminole'; $letters = range('A','Z'); $letter = isset($_GET['letter']) && in_array($_GET['letter'], $letters) ? $_GET['letter'] : 'A'; function slugify($cat){ return strtolower(trim(preg_replace('/[^a-z0-9]+/i','-',$cat),'-')); } function city_folder($city){ return ucfirst(strtolower(str_replace(' ','-',$city))); } $cats = $categories[$letter] ?? []; $cityFolder = city_folder($city); $bdoBase = "/geo/$country/$state/$cityFolder/business.php?type="; $bbbBase = "https://www.bbb.org/us/".strtolower($state)."/".strtolower(str_replace(' ','-',$city))."/category/"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Categories Starting with <?= htmlspecialchars($letter) ?> in <?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?> | Local Business Directory | BestDealOn</title> <meta name="description" content="Explore all business categories starting with <?= $letter ?> in <?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?>. Find top-rated local businesses, services, and professionals. Discover the best deals, BBB listings, and more with BestDealOn's local directory for <?= $city ?>, <?= $state ?>."> <link rel="canonical" href="https://bestdealon.com/cat/?country=<?= urlencode($country) ?>&state=<?= urlencode($state) ?>&city=<?= urlencode($city) ?>&letter=<?= $letter ?>"> <meta name="robots" content="index,follow"> <!-- Open Graph / Facebook --> <meta property="og:title" content="Categories Starting with <?= $letter ?> - <?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?> | BestDealOn"> <meta property="og:description" content="Browse all local business categories starting with <?= $letter ?> in <?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?>. Discover top businesses and deals."> <meta property="og:type" content="website"> <meta property="og:url" content="https://bestdealon.com/cat/?country=<?= urlencode($country) ?>&state=<?= urlencode($state) ?>&city=<?= urlencode($city) ?>&letter=<?= $letter ?>"> <meta property="og:locale" content="en_US"> <meta property="og:site_name" content="BestDealOn"> <meta property="og:image" content="https://bestdealon.com/images/local-business-directory.jpg"> <!-- Twitter Card --> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:title" content="Business Categories in <?= $city ?>, <?= $state ?> | BestDealOn"> <meta name="twitter:description" content="Find all business categories starting with <?= $letter ?> in <?= $city ?>, <?= $state ?>. Local directory powered by BestDealOn."> <meta name="twitter:image" content="https://bestdealon.com/images/local-business-directory.jpg"> <!-- Structured Data (all identical to prior version) --> <script type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://bestdealon.com/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https://bestdealon.com/cat/"},{"@type":"ListItem","position":3,"name":"<?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?>","item":"https://bestdealon.com/cat/?state=<?= urlencode($state) ?>&city=<?= urlencode($city) ?>"},{"@type":"ListItem","position":4,"name":"Starting with <?= $letter ?>","item":"https://bestdealon.com/cat/?state=<?= urlencode($state) ?>&city=<?= urlencode($city) ?>&letter=<?= $letter ?>"}]}</script> <script type="application/ld+json"> {"@context":"https://schema.org","@type":"ItemList","name":"Business Categories Starting with <?= $letter ?> in <?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?>","itemListOrder":"http://schema.org/ItemListOrderAscending","numberOfItems":<?= count($cats) ?>,"itemListElement":[<?php foreach($cats as $i=>$cat): ?>{"@type":"ListItem","position":<?= $i+1 ?>,"name":"<?= htmlspecialchars($cat['name']) ?>","url":"https://bestdealon.com/geo/<?= $country ?>/<?= $state ?>/<?= $cityFolder ?>/business.php?type=<?= slugify($cat['name']) ?>"}<?= $i<count($cats)-1?',':'' ?><?php endforeach; ?>]}</script> <script type="application/ld+json">{"@context":"https://schema.org","@type":"City","name":"<?= ucwords(str_replace('-', ' ', $city)) ?>","address":{"@type":"PostalAddress","addressLocality":"<?= ucwords(str_replace('-', ' ', $city)) ?>","addressRegion":"<?= $state ?>","addressCountry":"<?= $country ?>"}}</script> <style> body{background:#f5f8fb;font-family:system-ui,Arial,sans-serif;margin:0;color:#095a76} .top-bar{background:#eee;padding:.8em 1.2em;font-weight:900;} .main{max-width:1200px;margin:2.5em auto 1em;padding:0 1em} h1{text-align:center;font-size:2.3rem;color:#016285;margin:0 0 .5em} .aznav{text-align:center;margin:1.4em 0 2em;font-size:1.22em} .aznav a,.aznav strong{color:#014b85;text-decoration:none;font-weight:700;margin:0 .09em;display:inline-block} .aznav a:hover{color:#e11e9c;text-decoration:underline} .geoinfo{text-align:center;margin-bottom:.7em} .geo-bar{display:inline-block;background:#d7ebfd;border-radius:12px;padding:.5em 1.1em;font-size:.97em;font-weight:500;color:#015c92;margin:0 auto 1.5em} .geobutton{background:#5b36ff;color:#fff;border:none;border-radius:6px;font-size:.98em;font-weight:600;padding:.36em 1em;margin-left:1.1em;cursor:pointer} .geobutton:disabled{opacity:.55;cursor:not-allowed} .geobutton:hover:not(:disabled){background:#3b289b} .catcols{display:flex;flex-wrap:wrap;gap:2em;justify-content:center;margin-top:1.6em} .catcol{flex:1 1 240px;min-width:220px;max-width:350px} .catcol ul{list-style:none;margin:0;padding:0} .catcol li{margin-bottom:.38em} .catcol a{color:#015c92;text-decoration:underline;font-size:1.05em} .catcol a:hover{color:#ee2266} /* Mobile dropdown */ .cat-select-block{display:none;text-align:center;margin:1.5em auto} .cat-select-block label{font-weight:700;color:#014b85} .cat-select-block select{margin-top:.5em;padding:.45em .6em;font-size:1.05em;border:1px solid #a9c5e0;border-radius:6px;max-width:90vw;width:320px} /* Link switch */ .link-switch-block{text-align:center;margin:1.2em 0} .switch-label{font-weight:700;color:#014b85;margin-right:.6em} .link-switch{position:relative;display:inline-block;width:160px;height:46px} .link-switch input{opacity:0;width:0;height:0} /* track */ .slider{position:absolute;top:0;left:0;right:0;bottom:0;cursor:pointer;background:#5b36ff;border-radius:34px;transition:.3s} /* knob */ .slider:before{position:absolute;content:"BDO";left:4px;bottom:4px;height:38px;width:74px;background:#fff;border-radius:30px; display:flex;align-items:center;justify-content:center;font-weight:700;font-size:.9em;color:#0a7b00;font-family:inherit;transition:.3s} /* track labels */ .switch-text{position:absolute;width:50%;top:50%;transform:translateY(-50%);font-size:.95em;font-weight:700;color:#fff;text-align:center;pointer-events:none} .switch-text.left{left:0} .switch-text.right{right:0} /* hide label under knob to avoid ghosting */ .link-switch input:not(:checked) ~ .switch-text.left{opacity:0} .link-switch input:checked ~ .switch-text.right{opacity:0} /* checked (BBB) */ input:checked + .slider{background:#2579b5} input:checked + .slider:before{transform:translateX(78px);content:"BBB"} /* Responsive */ @media(max-width:600px){ .catcols{display:none} .cat-select-block{display:block} h1{font-size:1.26em} .main{padding:0 .15em} } .nearby-block{margin:1.2em auto;max-width:660px;text-align:center;background:#fffbe9;border:1.2px solid #f5c867;border-radius:11px;padding:.9em .7em} .nearby-block .title{font-weight:700;color:#ce980c;margin-bottom:.4em} .nearby-block .citylinks a{margin:0 .7em 0 0;color:#384bb6;text-decoration:underline;display:inline-block} .nearby-block .citylinks a:hover{color:#e11e9c} </style> </head> <div class="top-bar"><a href="/" style="text-decoration:none;color:#2a3ca5">BestDealOn</a> »Local Categories</div> <body> <div class="main"> <h1>Categories Starting with <?= htmlspecialchars($letter) ?> - <?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?></h1> <p style="text-align:center;color:#31688a;font-size:1.06em;max-width:700px;margin:0 auto 1.2em"> Browse local business categories that start with the letter <?= $letter ?> in <?= ucwords(str_replace('-', ' ', $city)) ?>, <?= $state ?>. Find trusted companies, professionals, and services—right here in your community. </p> <!-- Link switch --> <div class="link-switch-block"> <span class="switch-label">Choose links:</span> <label class="link-switch"> <input type="checkbox" id="linkSwitch" aria-label="Toggle between BestDealOn and BBB links"> <span class="slider"></span> <span class="switch-text left">BDO</span> <span class="switch-text right">BBB</span> </label> </div> <!-- Mobile dropdown --> <div class="cat-select-block"> <label for="cat-select">Select a category:</label><br> <select id="cat-select"> <option value="">-- Select Category --</option> <?php foreach($cats as $cat): $slug=slugify($cat['name']); $bdoHref=$bdoBase.urlencode($slug); $bbbHref=$bbbBase.urlencode($slug); ?> <option value="<?= htmlspecialchars($bdoHref) ?>" data-bdo="<?= htmlspecialchars($bdoHref) ?>" data-bbb="<?= htmlspecialchars($bbbHref) ?>"> <?= htmlspecialchars($cat['name']) ?> </option> <?php endforeach; ?> </select> </div> <!-- Alphabet navigation --> <div class="aznav"> <?php foreach($letters as $az): ?> <?= ($az === $letter) ? "<strong>$az</strong>" : '<a href="?country='.urlencode($country).'&state='.urlencode($state).'&city='.urlencode($city).'&letter='.$az.'">'.$az.'</a>' ?> <?php endforeach; ?> </div> <!-- Geolocate --> <div class="geoinfo"> <span class="geo-bar"> Current Location: <?= htmlspecialchars(ucwords(str_replace('-', ' ', $city))) ?>, <?= htmlspecialchars($state) ?>, <?= htmlspecialchars($country) ?> <button class="geobutton" id="geolocate-btn" onclick="locateMeCategories('<?= $letter ?>', this)">Geolocate Me</button> </span> <span id="geo-status" style="color:#333;margin-left:.8em;"></span> </div> <div id="nearby-cities"></div> <!-- Desktop list --> <?php $colCount=3;$perCol=$cats?ceil(count($cats)/$colCount):1;$chunks=array_chunk($cats,$perCol); ?> <div class="catcols" id="catcols"> <?php foreach($chunks as $col): ?> <div class="catcol"><ul> <?php foreach($col as $cat): $slug=slugify($cat['name']); $bdoHref=$bdoBase.urlencode($slug); $bbbHref=$bbbBase.urlencode($slug); ?> <li><a href="<?= htmlspecialchars($bdoHref) ?>" data-bdo="<?= htmlspecialchars($bdoHref) ?>" data-bbb="<?= htmlspecialchars($bbbHref) ?>" target="_self"><?= htmlspecialchars($cat['name']) ?></a></li> <?php endforeach; ?> </ul></div> <?php endforeach; ?> </div> </div> <script> const STATES_BOUNDS_URL='/geo/json-data/states-bounds.json'; const CITY_LIST_BASE='/geo/json-data/'; let currentLinkType='bdo'; function findStateByLatLon(lat,lon,bounds){return bounds.find(b=>lat>=b.minLat&&lat<=b.maxLat&&lon>=b.minLon&&lon<=b.maxLon)?.state||'';} function showNearbyCities(state,lat,lon,letter,curCity){ fetch(CITY_LIST_BASE+state+'.json').then(r=>r.json()).then(cs=>{ let list=cs.map(c=>({...c,d:Math.hypot(lat-c.lat,lon-c.lon)})).sort((a,b)=>a.d-b.d); let html='<div class="nearby-block"><div class="title">Choose your city below:</div><div class="citylinks">'+ [list[0],...list.slice(1).filter(x=>x.city.toLowerCase()!==curCity.toLowerCase()).slice(0,5)] .map(nb=>`<a href="?country=USA&state=${encodeURIComponent(state)}&city=${encodeURIComponent(nb.city)}&letter=${letter}">${nb.city}</a>`).join(' ')+'</div></div>'; document.getElementById('nearby-cities').innerHTML=html; document.getElementById('geo-status').textContent=''; }); } function locateMeCategories(letter,btn){ if(!navigator.geolocation){alert("Geolocation not supported.");return;} if(btn.disabled)return; btn.disabled=true;document.getElementById('geo-status').textContent='Detecting...'; navigator.geolocation.getCurrentPosition(pos=>{ fetch(STATES_BOUNDS_URL).then(r=>r.json()).then(b=>{ let s=findStateByLatLon(pos.coords.latitude,pos.coords.longitude,b); if(!s){alert('State not detected.');btn.disabled=false;document.getElementById('geo-status').textContent='';return;} showNearbyCities(s,pos.coords.latitude,pos.coords.longitude,letter,'<?= addslashes($city) ?>'); }); },()=>{alert('Geolocation failed.');btn.disabled=false;document.getElementById('geo-status').textContent='';}); } /* link switch */ function switchLinks(t){ currentLinkType=t; document.querySelectorAll('#catcols a[data-bdo]').forEach(a=>{ a.href=t==='bdo'?a.dataset.bdo:a.dataset.bbb; a.target=t==='bdo'?'_self':'_blank'; }); document.querySelectorAll('#cat-select option[data-bdo]').forEach(o=>{ o.value=t==='bdo'?o.dataset.bdo:o.dataset.bbb; }); } document.getElementById('linkSwitch').addEventListener('change',e=>switchLinks(e.target.checked?'bbb':'bdo')); /* mobile nav */ document.getElementById('cat-select').addEventListener('change',function(){ if(this.value){currentLinkType==='bbb'?window.open(this.value,'_blank'):location.href=this.value;} }); </script> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel