function smart_paging_url_inbound_alter in Smart Paging 7
Same name and namespace in other branches
- 7.2 smart_paging.module \smart_paging_url_inbound_alter()
Implements hook_url_inbound_alter().
File
- ./
smart_paging.module, line 528 - Provides smart paging capability to Drupal contents.
Code
function smart_paging_url_inbound_alter(&$path, &$original_path, $path_language) {
if (variable_get('smart_paging_enable_clean_url', TRUE)) {
$arg_count = count(arg()) - 1;
$page = arg($arg_count);
$sub_page = arg($arg_count - 1);
// Check if path has pattern of http://example.com/<path alias>/<pager prefix>/<sub_page>/<page>
if ($arg_count > 2 && is_numeric($sub_page) && is_numeric($page)) {
if (arg($arg_count - 2) == variable_get('smart_paging_path_prefix', 'page')) {
// Set the 'page' value of GET method
$_GET['page'] = "{$sub_page},{$page}";
// Extract alias from arg()
$alias = arg();
unset($alias[$arg_count - 2], $alias[$arg_count - 1], $alias[$arg_count]);
// Get the Drupal system URL for a path alias
if (!($drupal_path = drupal_lookup_path('source', implode('/', $alias), $path_language)) && function_exists("path_alias_xt_get_normal_path")) {
$drupal_path = path_alias_xt_get_normal_path(implode('/', $alias), $path_language);
}
if (!empty($drupal_path)) {
// Alter inbound URL request
$path = $drupal_path;
}
else {
$path = implode('/', $alias);
}
}
}
}
}