Created
October 28, 2011 15:01
-
-
Save markupboy/1322478 to your computer and use it in GitHub Desktop.
city and state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $states = array( | |
| "MD" => array("title" => "Maryland", "cities" => array()), | |
| "VA" => array("title" => "Virginia", "cities" => array()), | |
| "NC" => array("title" => "North Carolina", "cities" => array()), | |
| "NJ" => array("title" => "New Jersey", "cities" => array()), | |
| "DC" => array("title" => "Washington DC", "cities" => array()) | |
| ); | |
| ?> | |
| {exp:weblog:categories category_group="4" weblog="property"} | |
| <?php | |
| $locations[] = array( | |
| "category_name" => "{category_name}", | |
| "category_url_title" => "{category_url_title}" | |
| ); | |
| ?> | |
| {/exp:weblog:categories} | |
| <?php | |
| foreach ($locations as $index => $city) { | |
| $location = split(", ", $city["category_name"]); | |
| $states[$location[1]]["cities"][] = $city; | |
| } | |
| ?> | |
| <h2>Filter By Location</h2> | |
| <ul class="full accordion"> | |
| <?php foreach ($states as $abbreviation => $state) { ?> | |
| <li class="expander"> | |
| <a><?php echo $state["title"]; ?></a> | |
| <ul> | |
| <?php foreach ($state["cities"] as $index => $city) { ?> | |
| <li> | |
| <a href="/mobile/apartments/city/<?php echo $city["category_url_title"] ?>"> | |
| <?php echo $city["category_name"] ?> | |
| </a> | |
| </li> | |
| <?php } ?> | |
| </ul> | |
| <?php } ?> | |
| </ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment