some sites have a button "Display as One page" next to the pager.. Is this hard to implement?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

solodky’s picture

Issue tags: +pagination, +page numbering

is it hard to include the page number such as Page 2 of 3 up near the node title? ..and also another instance of the pager to complement the pager set at the bottom with another one at the top like a real peace of software?

arpeggio’s picture

Hi solodky, "Display as One page" is a challenging feature to develop, anyway I'll work on this feature on my free time. Of course, patches are always welcome. The "Page 2 of 3" feature is already implemented #1177620: Page title suffix should not be added via drupal_set_title. Thank you.

chegor’s picture

Anybody can suggest a solution?

jtoth624’s picture

I am currently implementing this. It's not fully contained within the module though (our "Display as One page" link is not part of the pagination bar) but it provides an option to specify an argument in the URL which disables smart paging for that page. I have a few things to button up on it then I plan to submit a patch.

arpeggio’s picture

Hi jtoth624, your patch is welcome. Thanks.

jtoth624’s picture

Here is a patch I created to "display as one page". This will disable smart paging if the argument "single=1" is present in the URL. It also takes the full node URL appended "?single=1" and makes that the canonical link, even when paging is still on. This makes the full page view the landing page for search engine results. If you wish to change the argument name from "single" to something else, be aware that it occurs in 2 locations after the patch is applied, once on line 690, and also on line 1070. One other thing worth noting is that for full view pages, I've disabled caching because it was causing a persistent cached copy to be served, I left the caching code commented out but not removed in this patch because I am not sure if it was problematic specifically due to memcache on our end, or in general.

jtoth624’s picture

Please disregard that last patch, I built it on our installed version instead of the latest, this one applies correctly.

I also want to add that if you'd like to add a link to the pager controls directly, you can do so by copying theme_pager() from pager.inc to your template.php file and adding something like the following before the return:

    //add a view all link to the pager
      $items[] = array(
        'class' => array('pager-all'),
        'data' => 'View Full Article',
        'data' => l(t('View Full Article'), url($_GET['q'], array('absolute' => true)), 
                                                       array('query' => array('single' => '1'))),
        );

I tried to include this today within the patch but I don't know of a way to override the pager outside of themes.

arpeggio’s picture

Status: Active » Fixed

Hi jtoth624, I have already implemented your patch. I made some improvements in your code. Also I changed the URL appended token from ?single=1 to ?nopaging=1. Thank you for sharing your patch.

jpstrikesback’s picture

Status: Fixed » Needs work

I'm noticing that the line break filter fails when using ?nopaging=1, this makes sense since the line break processing happens after we've said return. I've added it back in before the return, thoughts?

            if (isset($query_parameters['nopaging'])) {
              // Prevent this page from being cached
              $GLOBALS['conf']['cache'] = FALSE;
              // If set, use "Convert line breaks into HTML" filter
              if (isset($use_autop)) {
                $build[$field_name][$delta]['#markup'] = _filter_autop($markup_content);                
              }
              return;
            }
jpstrikesback’s picture

Status: Needs work » Needs review
FileSize
1.6 KB

Here is a patch

jpstrikesback’s picture

To use this should Smart Paging provide it's own theme function that overrides theme_pager()? I've gone the template route but that seems rather brittle, perhaps it's fine:

Inside MY_TEMPLATE_pager() before the return:

    //add a view all link to the text body smart_pager
    if ($element == 1) {
      $items[] = array(
        'class' => array('pager-all'),
        'data' => 'Show All',
        'data' => l(t('Show All'), url($_GET['q'], array('absolute' => true)), array('query' => array('nopaging' => '1'))),
      );
    }
jtoth624’s picture

This is how I am altering the pager bar too (as I posted in comment #7). I couldn't come up with a way to alter theme_pager() from within a module so I extended it in template.php.

arpeggio’s picture

Status: Needs review » Fixed

Hi jpstrikesback, I have already pushed your patch. Please use the deve version. Thank you for sharing your patch.

@Theme for pager, please open new issue. Thanks.

Status: Fixed » Closed (fixed)

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

marcelovani’s picture

This piece of code is causing the canonical rel to be displayed twice, because Metatag module is responsible for setting this

function smart_paging_html_head_alter(&$head_elements) {
  global $base_root;
  if (isset($head_elements['smart_paging_on'])) {
    // Set the single page view URL as canonical.
    unset($head_elements['smart_paging_on']);
    $url_components = parse_url($base_root);
    $args = $_GET;
    unset($args['q']);
    $args['nopaging'] = 1;
    $args = http_build_query($args);
    $url_path = $url_components['host'] . '/' . request_path();
    $canonical_link = $url_components['scheme'] . "://$url_path?$args";

Continuing on https://drupal.org/node/1942266