Site Builder
Editing:
index.php
writable 0666
<?php /* ------------ data helpers (unchanged) ------------ */ $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($s){ return strtolower(trim(preg_replace('/[^a-z0-9]+/i','-',$s),'-')); } function city_folder($c){ return ucfirst(strtolower(str_replace(' ','-',$c))); } $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"> <link rel="icon" href="/bestdealon.svg" type="image/svg+xml"> <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 --> <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 ?>."> <meta name="twitter:image" content="https://bestdealon.com/images/local-business-directory.jpg"> <!-- Structured data (unchanged) --> <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"><?php echo json_encode([ "@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"=>array_values(array_map(function($c,$i) use($country,$state,$cityFolder){ return ["@type"=>"ListItem","position"=>$i+1,"name"=>$c['name'],"url"=>"https://bestdealon.com/geo/$country/$state/$cityFolder/business.php?type=".slugify($c['name'])]; },$cats,array_keys($cats))) ],JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);?></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> /* --- basics --- */ body{margin:0;background:#f5f8fb;font-family:system-ui,Arial,sans-serif;color:#095a76} .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} /* --- YOUR ORIGINAL HEADER (logo + nav lable) --- */ .top-bar{background:#eee;padding:.8em 1.2em;font-weight:900;} /* --- navigation letters (hidden but kept for SEO) --- */ .aznav{display:none} /* --- 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} .slider{position:absolute;top:0;left:0;right:0;bottom:0;cursor:pointer;background:#5b36ff;border-radius:34px;transition:.3s} .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;transition:.3s} .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} .link-switch input:not(:checked)~.switch-text.left{opacity:0} .link-switch input:checked~.switch-text.right{opacity:0} input:checked+.slider{background:#2579b5} input:checked+.slider:before{transform:translateX(78px);content:"BBB"} /* --- dropdowns (now always visible) --- */ .select-block{margin:1.4em auto;text-align:center} .select-block label{font-weight:700;color:#014b85} .select-block select{margin-top:.45em;padding:.45em .6em;font-size:1.05em;border:1px solid #a9c5e0;border-radius:6px;width:320px;max-width:90vw} /* --- category cols kept for desktop (optional) --- */ @media(max-width:600px){.catcols{display:none}} .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} /* --- geo bar & nearby city styles (unchanged) --- */ .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} .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> <body> <!-- ORIGINAL HEADER (logo + description) --> <div class="top-bar"><a href="/" style="text-decoration:none;color:#000000">BestDealOn</a> » Categories</div> <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> <!-- ALWAYS‑VISIBLE SELECTORS --> <div class="select-block"> <label for="letter-select">Select first letter:</label><br> <select id="letter-select"> <option value="">-- Select Letter --</option> <?php foreach($letters as $az): ?> <option value="<?= $az ?>" <?= $az==$letter?'selected':'' ?>><?= $az ?></option> <?php endforeach; ?> </select> </div> <div class="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> <!-- hidden A‑Z nav still present for SEO --> <div class="aznav" aria-hidden="true"> <?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 bar --> <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 columns --> <?php $perCol = $cats ? ceil(count($cats)/3) : 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> /* -------- letter dropdown -------- */ document.getElementById('letter-select').addEventListener('change',function(){ if(this.value){ const url=new URL(window.location.href); url.searchParams.set('letter',this.value); window.location.href=url.toString(); } }); /* -------- link switch / dropdown updates -------- */ let currentLinkType='bdo'; 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')); document.getElementById('cat-select').addEventListener('change',function(){ if(this.value){ currentLinkType==='bbb'?window.open(this.value,'_blank'):location.href=this.value; } }); /* -------- geolocation (unchanged) -------- */ const STATES_BOUNDS_URL='/geo/json-data/states-bounds.json'; const CITY_LIST_BASE='/geo/json-data/'; function findState(lat,lon,bounds){return bounds.find(b=>lat>=b.minLat&&lat<=b.maxLat&&lon>=b.minLon&&lon<=b.maxLon)?.state||'';} function showNearby(state,lat,lon,letter,curCity){ fetch(CITY_LIST_BASE+state+'.json').then(r=>r.json()).then(cs=>{ const list=cs.map(c=>({...c,d:Math.hypot(lat-c.lat,lon-c.lon)})).sort((a,b)=>a.d-b.d); document.getElementById('nearby-cities').innerHTML= '<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('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=>{ const st=findState(pos.coords.latitude,pos.coords.longitude,b); if(!st){alert('State not detected.');btn.disabled=false;document.getElementById('geo-status').textContent='';return;} showNearby(st,pos.coords.latitude,pos.coords.longitude,letter,'<?= addslashes($city) ?>'); }); },()=>{alert('Geolocation failed.');btn.disabled=false;document.getElementById('geo-status').textContent='';}); } </script> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel