views_isotope_example.module in Views Isotope (Deprecated) 7.2
Simple example module.
File
views_isotope_example/views_isotope_example.moduleView source
<?php
/**
* @file
* Simple example module.
*/
/**
* Page callback.
*
* This is an example of using standard theme functions to output your own
* lists, without using views.
*
* @return array
* Drupal render array.
*/
function views_isotope_example_theme_page() {
$return[] = array(
'#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 = 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', 'views_isotope_example') . '/views_isotope_example.css',
),
),
);
return $return;
}
/**
* Implements hook_views_api().
*/
function views_isotope_example_views_api() {
return array(
'api' => 3.0,
);
}
/**
* Implements hook_preprocess_views_view().
*/
function views_isotope_example_preprocess_views_view(&$vars) {
if ($vars['name'] == 'isotope_example') {
drupal_add_css(drupal_get_path('module', 'views_isotope_example') . '/views_isotope_example.css');
}
}
/**
* Implements hook_node_info().
*/
function views_isotope_example_node_info() {
return array(
'views_isotope_example' => array(
'name' => t('Isotope Example Node Type'),
'base' => 'views_isotope_example',
'description' => t('This is an example node type with a few fields.'),
'title_label' => t('Example Title'),
'locked' => TRUE,
),
);
}
/**
* Implements hook_menu().
*/
function views_isotope_example_menu() {
$items['isotope-example'] = array(
'title' => 'Isotope Examples',
'page callback' => 'views_isotope_example_page',
'access callback' => TRUE,
);
$items['isotope-example/theme-example'] = array(
'title' => 'Isotope Theme Example',
'page callback' => 'views_isotope_example_theme_page',
'access callback' => TRUE,
);
return $items;
}
/**
* Page callback.
*
* @return array
* Drupal render array.
*/
function views_isotope_example_page() {
$links[] = l(t('Theme Example'), 'isotope-example/theme-example');
if (module_exists('views_isotope_views')) {
$links[] = l(t('Views Example'), 'isotope-example/views-example');
}
$return[] = array(
'#theme' => 'item_list',
'#items' => $links,
'#type' => 'ul',
);
return $return;
}
Functions
Name | Description |
---|---|
views_isotope_example_menu | Implements hook_menu(). |
views_isotope_example_node_info | Implements hook_node_info(). |
views_isotope_example_page | Page callback. |
views_isotope_example_preprocess_views_view | Implements hook_preprocess_views_view(). |
views_isotope_example_theme_page | Page callback. |
views_isotope_example_views_api | Implements hook_views_api(). |