Site Builder
Editing:
indexrrrrr.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))); } $pageTitle = "Categories Starting with $letter - " . ucwords(str_replace('-', ' ', $city)) . ", $state"; $pageDesc = "Browse all business categories starting with $letter in " . ucwords(str_replace('-', ' ', $city)) . ", $state. Click any category to find local businesses or get listed!"; // Categories for this letter $cats = isset($categories[$letter]) ? $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"> <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: Breadcrumb --> <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> <!-- Structured Data: ItemList (Categories) --> <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> <!-- Structured Data: City --> <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;} .main { max-width:1200px; margin:2.5em auto 1em; padding:0 1em;} h1 { text-align:center; font-size:2.3rem; color:#016285; margin-bottom:.5em; margin-top:0;} .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 auto;} .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 styles --- */ .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;} /* --- Stylish link switch --- */ .link-switch-block{margin:1.2em 0 1.2em; text-align:center;} .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;cursor:pointer;top:0;left:0;right:0;bottom:0;background:#5b36ff;border-radius:34px;transition:.3s;} .slider:before{position:absolute;content:"";height:38px;width:74px;left:4px;bottom:4px;background:#ffffff;border-radius:30px;transition:.3s;} input:checked + .slider{background:#2579b5;} input:checked + .slider:before{transform:translateX(78px);} .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;} @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 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> <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> <!-- NEW link‑type switch block --> <div class="link-switch-block"> <span class="switch-label">Choose links:</span> <label class="link-switch"> <input type="checkbox" id="linkSwitch"> <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 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 multi‑column list --> <?php $colCount = 3; $num = count($cats); $perCol = $num > 0 ? ceil($num/$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'; // default – matches unchecked switch /* ---------- Geolocation ------------- */ function findStateByLatLon(lat, lon, stateBounds) { for(let i=0;i<stateBounds.length;i++){ let st = stateBounds[i]; if(lat >= st.minLat && lat <= st.maxLat && lon >= st.minLon && lon <= st.maxLon) return st.state; } return ''; } function showNearbyCitiesAndChoose(state, userLat, userLon, letter, country, curCity) { fetch(CITY_LIST_BASE + state + '.json') .then(r=>r.json()).then(cities=>{ let dists = cities.map(c => { let d = Math.hypot(userLat - c.lat, userLon - c.lon); return { city: c.city, state: state, country: country, d }; }); dists.sort((a, b) => a.d - b.d); let [nearest, ...nearby] = dists; let filtered = [nearest].concat( nearby.filter(nb => nb.city.toLowerCase() !== (curCity||'').toLowerCase()).slice(0,5) ); let html = '<div class="nearby-block"><div class="title">Choose your city below:</div><div class="citylinks">' + filtered.map(nb => { let href = '?country='+encodeURIComponent(nb.country)+'&state='+encodeURIComponent(state)+'&city='+encodeURIComponent(nb.city)+'&letter='+encodeURIComponent(letter); return '<a href="'+href+'">'+nb.city+'</a>'; }).join(' ') + /* SPACE between links */ '</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(function(pos) { let lat = pos.coords.latitude, lon = pos.coords.longitude; fetch(STATES_BOUNDS_URL).then(r=>r.json()).then(stateBounds=>{ let state = findStateByLatLon(lat, lon, stateBounds); if(!state) { alert('State not detected from location.'); document.getElementById('geo-status').textContent = ''; btn.disabled=false; return; } showNearbyCitiesAndChoose(state, lat, lon, letter, 'USA', '<?= addslashes($city) ?>'); }); }, function(){ alert("Geolocation failed."); document.getElementById('geo-status').textContent = ''; btn.disabled=false; }); } /* ---------- Link‑type switch (BDO / BBB) ---------- */ function switchLinks(type) { currentLinkType = type; // Desktop links var links = document.querySelectorAll('#catcols a[data-bdo]'); links.forEach(function(link){ link.href = (type==='bdo') ? link.getAttribute('data-bdo') : link.getAttribute('data-bbb'); link.target = (type==='bdo') ? '_self' : '_blank'; }); // Mobile options var options = document.querySelectorAll('#cat-select option[data-bdo]'); options.forEach(function(opt){ opt.value = (type==='bdo') ? opt.getAttribute('data-bdo') : opt.getAttribute('data-bbb'); }); } document.getElementById('linkSwitch').addEventListener('change', function(){ switchLinks(this.checked ? 'bbb' : 'bdo'); }); /* ---------- Mobile dropdown navigation ---------- */ document.getElementById('cat-select').addEventListener('change', function(){ var url = this.value; if(url){ if(currentLinkType === 'bbb'){ window.open(url, '_blank'); }else{ window.location.href = url; } } }); </script> </body> </html>
Save changes
Create folder
writable 0777
Create
Cancel