You are here

function isotope_example_theme_page in Isotope (with Masonry and Packery) 7.2

Page callback.

This is an example of using standard theme functions to output your own lists, without using views.

Return value

array Drupal render array.

1 string reference to 'isotope_example_theme_page'
isotope_example_menu in isotope_example/isotope_example.module
Implements hook_menu().

File

isotope_example/isotope_example.module, line 16
Simple example module.

Code

function isotope_example_theme_page() {
  $return[] = array(
    '#markup' => t('<p>You can explore this example for yourself at <strong>isotope_example_page()</strong>.</p>'),
  );

  // The label can be anything, including images, etc. Filtering happens on the
  // key.
  $colors = array(
    'blue' => 'Blue',
    'red' => '<span class="thisIsCustomisedLabel">Red</span>',
    'yellow' => 'Yellow',
  );
  $return[] = array(
    '#theme' => 'isotope_filter',
    '#items' => $colors,
    // Optional filtername: unique to distinguish it from the other filters on
    // the page.
    '#filtername' => 'color',
    // Optional filtertitle: displayed as a list title.
    '#filtertitle' => t('Colour'),
  );
  $sizes = array(
    'small' => 'Small',
    'wide' => 'Wide',
    'big' => 'Big',
    'tall' => 'Tall',
  );
  $return[] = array(
    '#theme' => 'isotope_filter',
    '#items' => $sizes,
    '#filtername' => 'size',
    '#filtertitle' => t('Size'),
  );
  $shapes = array(
    'round' => 'Round',
    'square' => 'Square',
  );
  $return[] = array(
    '#theme' => 'isotope_filter',
    '#items' => $shapes,
    '#filtername' => 'shape',
    '#filtertitle' => t('Shapes'),
    '#instance' => 1,
  );
  $sorts = array(
    'Size' => 'size',
    'shape',
    'color',
    array(
      'color',
      'size',
    ),
    'Color then Shape' => array(
      'color',
      'shape',
    ),
  );
  $return[] = array(
    '#theme' => 'isotope_sorter',
    '#sorts' => $sorts,
    '#original' => 'Original',
    '#instance' => 1,
  );

  // Create items of every size shape and color.
  $items = array();
  foreach ($sizes as $size => $label1) {
    foreach ($shapes as $shape => $label2) {
      foreach ($colors as $color => $label3) {
        $items[] = array(
          'value' => '<p>Item</p>',
          'data' => array(
            'size' => $size,
            'shape' => $shape,
            'color' => $color,
          ),
        );
      }
    }
  }
  $return[] = array(
    '#theme' => 'isotope_grid',
    '#items' => $items,
    '#instance' => 1,
    '#attached' => array(
      'css' => array(
        drupal_get_path('module', 'isotope_example') . '/isotope_example.css',
      ),
    ),
  );
  return $return;
}