views_ajax_get.module in Views Ajax Get 7
Same filename and directory in other branches
Allows Views ajax to work with GET instead of POST.
File
views_ajax_get.moduleView source
<?php
/**
* @file
* Allows Views ajax to work with GET instead of POST.
*/
/**
* Implements hook_menu().
*/
function views_ajax_get_menu() {
$items = array();
$items['admin/config/system/views_ajax_get'] = array(
'title' => 'Views Ajax Get Settings',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'views_ajax_get_admin_form',
),
'access arguments' => array(
'administer views ajax get',
),
'file' => 'views_ajax_get.admin.inc',
);
return $items;
}
/**
* Implements hook_views_pre_render().
*
* Include the necessary JavaScript file if an Ajax view is embedded
* on the page.
*/
function views_ajax_get_views_pre_render(&$view) {
$exempt_views = variable_get('views_ajax_get_exemptions', array());
if ($view->use_ajax && empty($view->is_attachment) && empty($view->live_preview) && (!isset($exempt_views[$view->name]) || !$exempt_views[$view->name])) {
drupal_add_js(drupal_get_path('module', 'views_ajax_get') . '/views_ajax_get.js');
$data = array(
'viewsAjaxGet' => array(
$view->name,
),
);
drupal_add_js($data, 'setting');
}
}
/**
* Implements hook_views_ajax_data_alter().
*
* Adding the headers for cache control so that these requests can be cached.
*/
function views_ajax_get_views_ajax_data_alter(&$commands, $view) {
$exempt_views = variable_get('views_ajax_get_exemptions', array());
// If view is excluded from conversion, don't add cache headers.
if (drupal_page_is_cacheable() && (!isset($exempt_views[$view->name]) || !$exempt_views[$view->name])) {
drupal_add_http_header('Cache-Control', 'public, max-age=' . variable_get('page_cache_maximum_age', 0));
}
}
/**
* Implements hook_permission().
*/
function views_ajax_get_permission() {
return array(
'administer views ajax get' => array(
'title' => t('Administer views ajax get'),
'description' => t('Access the views get administration pages.'),
'restrict access' => TRUE,
),
);
}
Functions
Name | Description |
---|---|
views_ajax_get_menu | Implements hook_menu(). |
views_ajax_get_permission | Implements hook_permission(). |
views_ajax_get_views_ajax_data_alter | Implements hook_views_ajax_data_alter(). |
views_ajax_get_views_pre_render | Implements hook_views_pre_render(). |