You are here

function views_isotope_example_theme_page in Brainstorm profile 7

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 'views_isotope_example_theme_page'
views_isotope_example_menu in modules/custom/views_isotope/views_isotope_example/views_isotope_example.module
Implements hook_menu().

File

modules/custom/views_isotope/views_isotope_example/views_isotope_example.module, line 17
Simple example module.

Code

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

  // The label can be anything, including images, etc. Filtering happens on the
  // key.
  $colors = [
    'blue' => 'Blue',
    'red' => '<span class="thisIsCustomisedLabel">Red</span>',
    'yellow' => 'Yellow',
  ];
  $return[] = [
    '#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 = [
    'small' => 'Small',
    'wide' => 'Wide',
    'big' => 'Big',
    'tall' => 'Tall',
  ];
  $return[] = [
    '#theme' => 'isotope_filter',
    '#items' => $sizes,
    '#filtername' => 'size',
    '#filtertitle' => t('Size'),
  ];
  $shapes = [
    'round' => 'Round',
    'square' => 'Square',
  ];
  $return[] = [
    '#theme' => 'isotope_filter',
    '#items' => $shapes,
    '#filtername' => 'shape',
    '#filtertitle' => t('Shapes'),
    '#instance' => 1,
  ];
  $sorts = [
    'Size' => 'size',
    'Shape' => 'shape',
    'Color' => 'color',
    'Color then Size' => [
      'color',
      'size',
    ],
    'Color then Shape' => [
      'color',
      'shape',
    ],
  ];
  $return[] = [
    '#theme' => 'isotope_sorter',
    '#sorts' => $sorts,
    '#original' => 'Original',
    '#instance' => 1,
  ];

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