Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 27th, 2012  |  syntax: None  |  size: 1.19 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.                 $states = array(
  3.                         "MD" => array("title" => "Maryland", "cities" => array()),
  4.                         "VA" => array("title" => "Virginia", "cities" => array()),
  5.                         "NC" => array("title" => "North Carolina", "cities" => array()),
  6.                         "NJ" => array("title" => "New Jersey", "cities" => array()),
  7.                         "DC" => array("title" => "Washington DC", "cities" => array())
  8.                 );
  9.         ?>
  10.  
  11.         {exp:weblog:categories category_group="4" weblog="property"}
  12.                 <?php
  13.                         $locations[] = array(
  14.                                 "category_name" => "{category_name}",
  15.                                 "category_url_title" => "{category_url_title}"
  16.                         );
  17.                 ?>
  18.         {/exp:weblog:categories}
  19.        
  20.         <?php
  21.        
  22.                 foreach ($locations as $index => $city) {
  23.                         $location = split(", ", $city["category_name"]);
  24.                         $states[$location[1]]["cities"][] = $city;
  25.                 }
  26.        
  27.         ?>
  28.  
  29.         <h2>Filter By Location</h2>
  30.         <ul class="full accordion">
  31.                 <?php foreach ($states as $abbreviation => $state) { ?>
  32.                        
  33.                         <li class="expander">
  34.                                 <a><?php echo $state["title"]; ?></a>
  35.                                 <ul>
  36.                                         <?php foreach ($state["cities"] as $index => $city) { ?>
  37.                                                 <li>
  38.                                                         <a href="/mobile/apartments/city/<?php echo $city["category_url_title"] ?>">
  39.                                                                 <?php echo $city["category_name"] ?>
  40.                                                         </a>
  41.                                                 </li>
  42.                                         <?php } ?>
  43.                                 </ul>
  44.                        
  45.                 <?php } ?>
  46.         </ul>