Hi everyone, just wondering whether anyone has had the same issue. After installing Smart Paging, I noticed that Ajax pagers for block displays generated by views stopped working.

Members fund testing for the Drupal project. Drupal Association Learn more


arpeggio’s picture

Hello, can you upload your views exported code of this block.

jodythai’s picture

I face the same problem too. This is my Views code:

-------------------- BEGIN VIEWS CODE ------------------
$view = new view;
$view->name = 'latest_books_sidebar';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Latest Books Sidebar';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Bài viết mới nhất';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'mini';
$handler->display->display_options['pager']['options']['items_per_page'] = '3';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['total_pages'] = '3';
$handler->display->display_options['pager']['options']['expose']['items_per_page_options_all'] = 0;
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Fields: Thumb Image */
$handler->display->display_options['fields']['field_image']['id'] = 'field_image';
$handler->display->display_options['fields']['field_image']['table'] = 'field_data_field_image';
$handler->display->display_options['fields']['field_image']['field'] = 'field_image';
$handler->display->display_options['fields']['field_image']['label'] = '';
$handler->display->display_options['fields']['field_image']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_image']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_image']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_image']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_image']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_image']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_image']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_image']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_image']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_image']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_image']['element_label_colon'] = 0;
$handler->display->display_options['fields']['field_image']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_image']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_image']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_image']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_image']['settings'] = array(
'image_style' => 'crop_thumbnail',
'image_link' => 'content',
$handler->display->display_options['fields']['field_image']['field_api_classes'] = 0;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = 1;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Field: Content: Post date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'node';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = '';
$handler->display->display_options['fields']['created']['exclude'] = TRUE;
$handler->display->display_options['fields']['created']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['created']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['created']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['created']['alter']['external'] = 0;
$handler->display->display_options['fields']['created']['alter']['trim'] = 0;
$handler->display->display_options['fields']['created']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['created']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['created']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['created']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['created']['alter']['html'] = 0;
$handler->display->display_options['fields']['created']['element_label_colon'] = 0;
$handler->display->display_options['fields']['created']['element_default_classes'] = 1;
$handler->display->display_options['fields']['created']['hide_empty'] = 0;
$handler->display->display_options['fields']['created']['empty_zero'] = 0;
$handler->display->display_options['fields']['created']['date_format'] = 'custom';
$handler->display->display_options['fields']['created']['custom_date_format'] = 'd M, Y';
/* Field: Fields: Category */
$handler->display->display_options['fields']['field_category']['id'] = 'field_category';
$handler->display->display_options['fields']['field_category']['table'] = 'field_data_field_category';
$handler->display->display_options['fields']['field_category']['field'] = 'field_category';
$handler->display->display_options['fields']['field_category']['label'] = '';
$handler->display->display_options['fields']['field_category']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_category']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_category']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_category']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_category']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_category']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_category']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_category']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_category']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_category']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_category']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_category']['element_label_colon'] = 0;
$handler->display->display_options['fields']['field_category']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_category']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_category']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_category']['click_sort_column'] = 'tid';
$handler->display->display_options['fields']['field_category']['field_api_classes'] = 0;
/* Field: Global: Custom text */
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
$handler->display->display_options['fields']['nothing']['table'] = 'views';
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing']['label'] = '';
$handler->display->display_options['fields']['nothing']['alter']['text'] = '[created] | [field_category]';
$handler->display->display_options['fields']['nothing']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['nothing']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['nothing']['alter']['external'] = 0;
$handler->display->display_options['fields']['nothing']['alter']['trim'] = 0;
$handler->display->display_options['fields']['nothing']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['nothing']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['nothing']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['nothing']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['nothing']['alter']['html'] = 0;
$handler->display->display_options['fields']['nothing']['element_label_colon'] = 0;
$handler->display->display_options['fields']['nothing']['element_default_classes'] = 1;
$handler->display->display_options['fields']['nothing']['hide_empty'] = 0;
$handler->display->display_options['fields']['nothing']['empty_zero'] = 0;
/* Sort criterion: Content: Sticky */
$handler->display->display_options['sorts']['sticky']['id'] = 'sticky';
$handler->display->display_options['sorts']['sticky']['table'] = 'node';
$handler->display->display_options['sorts']['sticky']['field'] = 'sticky';
$handler->display->display_options['sorts']['sticky']['order'] = 'DESC';
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Book: Depth */
$handler->display->display_options['filters']['depth']['id'] = 'depth';
$handler->display->display_options['filters']['depth']['table'] = 'book_menu_links';
$handler->display->display_options['filters']['depth']['field'] = 'depth';
$handler->display->display_options['filters']['depth']['value']['value'] = '1';
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'book' => 'book',
/* Filter criterion: Content translation: Language */
$handler->display->display_options['filters']['language']['id'] = 'language';
$handler->display->display_options['filters']['language']['table'] = 'node';
$handler->display->display_options['filters']['language']['field'] = 'language';
$handler->display->display_options['filters']['language']['value'] = array(

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'latest_books_block');
$translatables['latest_books_sidebar'] = array(
t('Bài viết mới nhất'),
t('Sort by'),
t('Items per page'),
t('- All -'),
t('[created] | [field_category]'),
------------------------- END VIEWS CODE ------------------

Btw, your module is amazing! Thank you for your contribute!!!

arpeggio’s picture

I will check on that. Thank you for providing your Views export.

dalin’s picture

Status: Active » Needs review
2.72 KB

Confirmed the problem. The problem is with smart_paging_url_outbound_alter() and smart_paging_url_inbound_alter().

According to the principal of "Small pieces loosely coupled" these functions should not be part of the Smart Paging module. Turning URL query strings into path segments is unrelated to paging. It should be in a separate module if it doesn't already exist.

This patch removes these functions.

arpeggio’s picture

Status: Needs review » Needs work

We can't remove the smart_paging_url_outbound_alter() and smart_paging_url_inbound_alter() hooks because those are responsible for clean URL paging.

william.lai’s picture

Hi, we have the same problem when using smart paging module and views ajax pager. We only have a content type using smart paging, while other do not need smart paging at all. In our case, the problem occur in other content type. If we cannot remove that two function, can we apply it to specific content type in these two function?


william.lai’s picture

Hi, it seem only the function smart_paging_url_outbound_alter() break the ajax view. i added two setting in admin page, excluded by path and by content type.
Here are the patch for it. Please check if it work for you or any better approach.


SNaKeMe’s picture

The patch don't work for me. I get these two notice:

Notice: Trying to get property of non-object in smart_paging_url_outbound_alter() (Zeile 509 von /.../sites/all/modules/smart_paging/smart_paging.module).

Notice: Undefined offset: 1 in smart_paging_url_outbound_alter() (Zeile 507 von /.../sites/all/modules/smart_paging/smart_paging.module).

SNaKeMe’s picture

With Smart Paging 1.3 Version i get these Warning:

Warning: Invalid argument supplied for foreach() in smart_paging_url_outbound_alter() (Zeile 507 von /.../sites/all/modules/smart_paging/smart_paging.module).

Is it possible to get the old .dev Version?

arpeggio’s picture

@william.lai thank you for the patch, but we need a solution that solves the issue and not workaround.
@SNaKeMe You may check here http://drupal.org/node/915374/commits.

jamiecuthill’s picture

Views uses the page anchors to build the post data for the ajax query, by removing the page variable from the query string, Views is no longer able to send the page variable through with the request.

There is no way to tell in hook_paging_url_outbound_alter() that the link is part of an AJAX view under which circumstances smart_paging may have been able to skip the rewriting of the path.

Patching views module to resolve this issue would be the wrong solution and URL excludes seems like a bit of a workaround.

jamiecuthill’s picture

Here is a work around I've come up with.

I will admit now it's not very efficient and is a little brittle but it solves the problem in all cases I have.

jamiecuthill’s picture

Status: Needs work » Needs review
Ashraf Amayreh’s picture

Status: Needs review » Needs work

Has this been resolved? In my case I have 2 blocks on the same node with non-ajax pagers for each block and they're both malfunctioning even with the latest patch. I'll try to investigate further but wanted to shake up the issue and get any possible feedback.

jamiecuthill’s picture

That sounds like a different issue. Have you set each block to use a different pager id?

Ashraf Amayreh’s picture

Yes, I did change the IDs to 5, 6. I'm also getting all these notices:

Notice: Undefined offset: 1 in theme_pager() (line 331 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_first() (line 459 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_previous() (line 489 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_next() (line 528 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_next() (line 529 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_last() (line 564 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_next() (line 528 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_next() (line 529 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_next() (line 528 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_next() (line 529 of /var/www/arij/includes/pager.inc).
Notice: Undefined offset: 1 in theme_pager_last() (line 564 of /var/www/arij/includes/pager.inc).

jamiecuthill’s picture

Status: Needs work » Needs review
linora’s picture

anyone solved? share it here,thank you!

fulminado’s picture

Hello everyone!
I ll post my solution. It's a workaround again but hope it helps.
So the problem occurred for me when in a view I DISABLED pager.
This view takes all the images from the current nid and makes a slideshow. With pager enabled, photos didn't cycle automatically and the smart paging controls were visible. So I disabled it. When I tried to refresh the page in which I used the block from that view, a blank page came up. After searching a lot I found this was a problem with Smart Paging. If it was enabled for "Full HTML" the page broke. If it was disabled, everything was running as it should.
So my solution was for the certain content type (named "Event Article" in my case) to avoid using "smart_paging_field_attach_view_alter()". This is what i did:
I wrapped the existing code in an if clause, that checked the current content type :

if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
//get current content type machine name
$n_type = $node->type;

if (!( $n_type == "event_article")) {
//here lies the existing code in smart_paging_field_attach_view_alter()

and voila!

I had the smart paging work in all the content types except the one causing problem to!

Again just a workaround not a fix. But this way you can use any element from the node object and deside whether it should use smart paging or not( eg content type, path ..)

Thanx for the great module!!!!

dlsmore’s picture

Since this is the only viable pagination module in Drupal 7, I think it's important to make sure it doesn't break the AJAX pagers used in Views. I would also love to see a solution to this.

jferrervalls’s picture

I would really like this to work too. I had to disable pagination on the website I'm in charge of, I didn't manage to find a solution.

pendaco’s picture

Jep, same here. Since the views module is widely used I think this goes for a lot of people.

Is it possible to turn it into an option; Use clean pager URLs, yes | no ?

Of course it would be best (SEO wise also) if the Views module changes their page formatting as well..

huahua.hgh’s picture

Version: 7.x-1.x-dev » 7.x-1.3
Category: bug » support
1.9 KB
839 bytes

I use #7 code, is ok! thanks william.lai very much!
i try alter the patch, also ok! hope can help you!

i think my method only deal with like this page: taxonomy/term/*
dont support node page

goto "admin/config/content/smart_paging"
set "Path to exclude in url outbound alter "
ex: taxonomy/term/* or its alias

valderama’s picture

another quickfix is to comment out the complete smart_paging_url_outbound_alter function.

this url altering happening there breaks views ajax pager, which also includes "load more" links from views_load_more module.

bbdata’s picture

I want to add that it does not only affect ajax pagers but the normal full pager as well.

Having a pager id of 0 will result in having the pager show up for the first page, but disappear for subsequent pages. Changing the pager id to something else other than 0 or 1 will render the pager but all the links will link to the page you are currently on with no arguments.

Commenting out the aforementioned smart_paging_url_outbound_alter() and smart_paging_url_inbound_alter() will correct all these problems.

I can understand why the author wants to keep the clean urls as a feature... I'll return if I can think of a workable solution rather than a work around.

sokrplare’s picture

Patch in #7 worked well for me too. Since Smart Paging is in the Manage Display section of each content type, I wonder if it would be possible to base a patch on that? I know it is a workaround, but seeing as this issue has been around for over a year and neither Views nor Smart Paging has an easy solution, a workaround might be the best we've got.

sokrplare’s picture

171.65 KB

Had missed comment #8 until we launched the site and found 30 gigs of logs filling up the database - uh-oh!

Added this in to prevent the error messages (tried making a patch, but couldn't seem to get the right old version to patch against - sorry!) starting at line 508 in smart_paging.module:

  preg_match('/node\/(\d+)/', $path, $matches);
  if(count($matches) >= 2 && !empty($matches[1])) {
    $node = node_load($matches[1]);
  if (!( drupal_match_path($path, $url_exclude) || (isset($node) && drupal_match_path($node->type, $ct_exclude)))) {

Screenshot diff attached for reference too.

mxh’s picture

Title: Smart Paging Breaks Views Module Ajax Pager » Smart Paging Breaks Views Pager
Status: Needs review » Active

On my installation it's not only AJAX which is broken, all Views with pagers use the same page url prefix as Smart Paging does, so when I switch with Smart Paging, also my views are being switched on the page.

arpeggio’s picture

Hi, as feature request at #1689636: Give a choice of URL format. /page/2/0 OR ?page=2, we have "Enable clean URL pagination" option at Smart Paging admin page. For temporary fix for this issue you may disable it so that hook_url_outbound_alter() and hook_url_inbound_alter() will be bypassed.
@covenantd, Smart Paging system works not only in node entity but also works with user and taxnomy term entities.

mxh’s picture

Looks good. Updating to 7.x-1.5 works for me, also with AJAX. Thank you!

mxh’s picture

Title: Smart Paging Breaks Views Pager » Clean URL pagination breaks Views Pager
Version: 7.x-1.3 » 7.x-1.5
micbar’s picture

Clean urls still break the Views pager in 7.x-1.7.

Any progress on this?
Does anybody know what causes this error?

dalin’s picture

@micbar there's a description of the problem in #4 and several patches on this issue that take at least 3 different approaches on how to fix it. You are welcome to advocate for any of those approaches.

extremal’s picture

Version: 7.x-1.5 » 7.x-1.8
1.63 KB

Updating a patch from #12 for the 7.x-1.8 module version

arpeggio’s picture

Issue summary: View changes
Status: Active » Fixed

Hi jamiecuthill,huahua.hgh,covenantd,extremal, I have pushed the latest patch. Thank you for contributing/sharing your patches.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.