1

I have a content type that has no limit on how many body fields it can have.

You can say that each body field represents a page in a book. You are supposed to switch page to see the next body field.

The client I am developing this site for needs to support visitors that have javascript disabled.

Is there a solution that makes it possible to add a pager for these fields using PHP?

1

If you can use Views, it'll be simple.

Views can provide each field's value as a row. Set it up to display fields, add your multivalue body field, filter by node id, and you can set up views pager to show one row per page.

Then, use Pathauto to create nice addresses for nodes of that type, like /multibody/[nid]. In views, use the same address and voila - node pages got overriden with your view. Use Global Redirect to redirect from /node/[nid] to /multibody/[nid] to make sure users will not end up reading whole node at once.

|improve this answer|||||
  • I am unfortunately not using a view though. The node is displayed as usual. – Frinsh Aug 29 '13 at 7:47
  • 2
    The big question is - can you override this content type's display with view? When there already is a tool to do what you need, developing it anew seems pretty useless to me. – Mołot Aug 29 '13 at 7:56
0

It is always better to check for contributed modules: The Smart Paging module seems like your solution.

Provides splitting up long Drupal content into sub pages by number of characters/words or by a placeholder HTML tag for node, user and taxonomy term entities.

Features

  • Smart Paging feature can be applied only to CCK fields (with text format) of node, user and taxonomy term entities. (Note: "Description" field of taxonomy term is not a CCK field.)
  • URL for sub pages is made more SEO friendly and works even for aliased URL path.
  • The user has more control over Smart Paging configuration. An option is provided at "Manage Display" page of an entity type whether to control Smart Paging display behavior during content editing or at "Manage Display" page itself.
  • Weight and visibility of Smart Paging can be controlled at "Manage Display" page of an entity type (bundle).
  • It integrates with the WYSIWYG module.
  • URL appended query argument ?nopaging=1 to display Smart Paging split pages as one page.
  • It provides additional page SEO.
  • It provides pagination with rel="next" and rel="prev".
  • It provides support for the Token module.
|improve this answer|||||
  • I believed it was only able to paginate one field, dividing it by <!--pagebreak--> and leaving other ones intact. Can it really paginate field by field? – Mołot Aug 30 '13 at 10:59
0

I managed to solve my own question.

I add a GET-parameter to the template to check what 'page' you want to view and print that out.

$chapter = $_GET['chapter'];
print $content['body']['#items'][$chapter]['safe_value'];

This is not necessarily the 'Drupal' way (Add dozens of modules to get it to work) of doing this but it works and it's lightweight!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.