Branches Overview

Last edited: 12/4/2017

Branches have two display types: list and detail. Additionally, a search form can be used to find branches.

Also see the branches API article.

Search Form

Here is an example search form which can be used to search for branches on different categories.

Prepaire the state search:

  $STATES = array(
           'AL' => 'Alabama',
           'AK' => 'Alaska',
           'AZ' => 'Arizona',
           'AR' => 'Arkansas',
           'CA' => 'California',
           'CO' => 'Colorado',
           'CT' => 'Connecticut',
           'DE' => 'Delaware',
           'DC' => 'Dist Columbia',
           'FL' => 'Florida',
           'GA' => 'Georgia',
           'HI' => 'Hawaii',
           'ID' => 'Idaho',
           'IL' => 'Illinois',
           'IN' => 'Indiana',
           'IA' => 'Iowa',
           'KS' => 'Kansas',
           'KY' => 'Kentucky',
           'LA' => 'Louisiana',
           'ME' => 'Maine',
           'MD' => 'Maryland',
           'MA' => 'Massachusetts',
           'MI' => 'Michigan',
           'MN' => 'Minnesota',
           'MS' => 'Mississippi',
           'MO' => 'Missouri',
           'MT' => 'Montana',
           'NE' => 'Nebraska',
           'NV' => 'Nevada',
           'NH' => 'New Hampshire',
           'NJ' => 'New Jersey',
           'NM' => 'New Mexico',
           'NY' => 'New York',
           'NC' => 'North Carolina',
           'ND' => 'North Dakota',
           'OH' => 'Ohio',
           'OK' => 'Oklahoma',
           'OR' => 'Oregon',
           'PA' => 'Pennsylvania',
           'PR' => 'Puerto Rico',
           'RI' => 'Rhode Island',
           'SC' => 'South Carolina',
           'SD' => 'South Dakota',
           'TN' => 'Tennessee',
           'TX' => 'Texas',
           'UT' => 'Utah',
           'VT' => 'Vermont',
           'VA' => 'Virginia',
           'WA' => 'Washington',
           'WV' => 'West Virginia',
           'WI' => 'Wisconsin',
           'WY' => 'Wyoming'
           );

    foreach ($STATES as $S => $name) {
      $stateSelect.="<option value='$S'>$name</option>";
    }

A few forms for different criteria:

Search by Zip Code:<form id="search_by_zip" method="get" action="/find-a-branch-results/">
   <fieldset>
      <p>
         <label for="zip" class="textbox">Search by Zip Code:</label>
         <input type="text" name="zip" value="" id="zip" class="textbox" />
         <label for="church_radius" class="textbox">Radius:</label> <select name="radius" id="radius">
           <option value="5">5 miles</option>
           <option value="20">20 miles</option>
           <option value="50">50 miles</option>
           <option value="100">100 miles</option>
         </select>
         <input type="submit" name="search_by_zip_go" value="Search" id="search_by_zip_go" />
      </p>

   </fieldset>
</form>

Search by state:
<form id="search_by_other" method="get" action="/find-a-branch-results/">
   <fieldset>
      <p>
         <label for="branch_state" class="textbox">Search By State:</label>
         <select name="branch_state" id="branch_state">
          <option value="">Choose a State</option>
          <?=$stateSelect?>
         </select>
         <input type="submit" name="search_by_other_go" value="Search" id="search_by_other_go" />
      </p>
   </fieldset>
</form>

Search by countries, only will show countries containing branches:
<form id="search_by_other" method="get" action="/find-a-branch-results/">
   <fieldset>
      <p>
         <label for="branch_country" class="textbox">Search By Country:</label>
         <select name="branch_country" id="branch_country">
          <option value="">Choose a Country</option>
          <?php
            getContent(
            "branch",
            "display:list",
            "groupby:country",
            "group_show:<option value="__slug__">__title__</option>"
            );
          ?>
         </select>
         <input type="submit" name="search_by_other_go" value="Search" id="search_by_other_go" />
      </p>
   </fieldset>
</form>

Branch List

Some PHP to prepaire the search:

if ($_GET['zip']) {
  $search=$_GET['zip'];
}
elseif ($_GET['branch_city'] && $_GET['branch_state']) {
  $state=$_GET['branch_state'];
  $city=$_GET['branch_city'];
  $search="US|$state|$city";
}

Example

<?php
  getContent(
  "branch",
  "display:list",
  "search_location:$search",
  "radius:".$_GET['radius'],
  "search_state:".$_GET['branch_state'],
  "search_country:".$_GET['branch_country'],
  "noshow:<p class="results">Your search for '__searchterm__' returned 0 results</p><div class="result"></div>",
  "before_show:<p class="results">Your search for __searchterm__ returned __records__ results</p>",
// for one google map above the results with pin points for each branch
//"before_show:__googlemap v3key='YOURGOOGLEMAPKEY' zoom='4'__",
  "show:<div class="result">",
  "show:<div class="map" id="branch__count__" style="width: 308px; height: 151px; margin-bottom: 10px"></div> __googlemap v3key='YOURGOOGLEMAPYEY' zoom='4' div='branch__count__'__",
  "show:<h3>__name__</h3>",
  "show:<table>",
  "show:<tr><th>Address:</th><td>__street__ __city__, __stateAB__ __zip__</td></tr>",
  "show:<tr><th>Postal Address:</th><td>__postal__</td></tr>",
  "show:<tr><th>Phone:</th><td>__phone__</td></tr>",
  "show:<tr><th>Web site:</th><td><a href='http://__website__'>__website__</a></td></tr>",
  "show:<tr><th>Email:</th><td>__email__</td></tr>",
  "show:<tr><td colspan="2">__description__</td></tr>",
  "show:</table>",
  "show:</div>"
);
?>

Branch Detail

Example<?php
   getContent(
    "branch",
    "display:detail",
    "find:".$_GET['slug'],
    "show:<div class="result">",
    "show:<div class="map" id="branch" style="width: 308px; height: 151px; margin-bottom: 10px"></div> __googlemap v3key='YOURGOOGLEMAPKEYHERE'' zoom='4' div='branch'__",
    "show:<h3>__name__</h3>",
    "show:<table>",
    "show:<tr><th>Address:</th><td>__street__ __city__, __stateAB__ __zip__</td></tr>",
    "show:<tr><th>Postal Address:</th><td>__postal__</td></tr>",
    "show:<tr><th>Phone:</th><td>__phone__</td></tr>",
    "show:<tr><th>Web site:</th><td><a href='http://__website__'>__website__</a></td></tr>",
    "show:<tr><th>Email:</th><td>__email__</td></tr>",
    "show:<tr><td colspan="2">__description__</td></tr>",
    "show:</table>",
    "show:</div>"
);
?>