You are here

function bef_test_install in Better Exposed Filters 8.3

Same name and namespace in other branches
  1. 8.5 tests/modules/bef_test/bef_test.install \bef_test_install()
  2. 8.4 tests/modules/bef_test/bef_test.install \bef_test_install()

Adds terms to the hierarchical "location" vocabulary.

File

tests/bef_test/bef_test.install, line 11

Code

function bef_test_install() {

  // Set up an example hierarchical terms in the "Location" vocab.
  $locations = array(
    'United States' => array(
      'California' => array(
        'San Francisco',
        'San Diego',
        'Santa Barbara',
      ),
      'Oregon' => array(
        'Portland',
        'Eugene',
      ),
      'Washington' => array(
        'Seattle',
        'Spokane',
        'Walla Walla',
      ),
    ),
    'Canada' => array(
      'British Columbia' => array(
        'Vancouver',
        'Victoria',
        'Whistler',
      ),
      'Alberta' => array(
        'Calgary',
        'Edmonton',
        'Lake Louise',
      ),
    ),
    'Mexico' => array(),
  );
  foreach ($locations as $country => $states) {
    $country_tid = _bef_test_add_term($country);
    if ($country_tid && !empty($states)) {
      foreach ($states as $state => $cities) {
        $state_tid = _bef_test_add_term($state, $country_tid);
        if ($state_tid && !empty($cities)) {
          foreach ($cities as $city) {
            _bef_test_add_term($city, $state_tid);
          }
        }
      }
    }
  }
}