I have a content type named "article" and a node template named "node--article.tpl.php" and would like to display my pager. How do I go about doing this? As far as I can tell a traditional pager would be displayed using something like this:

// not sure where total comes from here, guessing I would query this
pager_default_initialize($total, 2, $element = 0);
$output = theme('pager', array('quantity' => $total));
print $output;

How would I go about doing this with this module? The formatting of the theme() function appears to spit out a URL with the format "/page/2/0" while the module formats it as "page/0/2". So the traditional approach does not seem to be valid here. I should note that I am able to navigate manually to these pages, so pagination and the filter are working fine. It is simply the display of the pager itself that I can't seem to get to work.

A last resort would be to somehow get the total page count from somewhere so I can just manually create a pager.

Thank you for your time.

-Mitchell

Comments

mitchellshelton’s picture

After digging through the code for this module I was unable to find anything to help me manually output the pager. Below is the call to the basic PHP function explode from line 745 in the file "smart_paging.module". This method also returns an array of the pages which could be used if needed. However, as I said, the module is working so this isn't completely needed. At least this will allow me to manually create the pager. Hopefully this will help others out. It would still be great if someone would provide a proper solution instead. I think at this point though, that would possibly qualify as a feature request and not documentation.


$placeholder = '

';
$pagebreak = array_filter(explode($placeholder, $node->body['und'][0]['safe_value']));
$pagecount = count($pagebreak);

arpeggio’s picture

Category: support » feature
Status: Active » Postponed (maintainer needs more info)

Hi, sorry for the late reply. Yes, we can't control the theme display of pager of Smart Paging using a theme template. Inside the process of replacing the Smart Paging placeholders and creating the pager is:
$build['smart_paging']['#markup'] = '<div class="smart-paging-pager">' . theme('pager', $variables) . '</div>';
We can add hook before that line so as have control. BTW, why do you need this feature?

mitchellshelton’s picture

It has been some time since I worked with this code, so I don't recall details as to why I needed it beyond what I stated in the original post. Since I was writing a custom node template it seemed necessary. I assume that anyone else that needs to heavily customize node output would have the same problem. Perhaps there is a better way to approach the problem.

Thank you,
-Mitchell

dzepol’s picture

We current are using this feature in our D6 site, using the pagination module. See #392580: Recent changes cause some headaches - Maybe some help on pagination module for more info. Really it is a matter of print images only on specific pages.

mikepvd’s picture

You can override the core pager theme in Drupal 7 two ways.

1. add a MY_THEME_pager(&$vars) to your template.php. You can copy the code from the core pager and modify it there.
2. add a HOOK_theme_registry_alter(&$theme_registry) to a custom module. Replace the entry for pager to point to whatever function / file you want.

If you don't want to override the core pager but want to take the existing Smart Pager pager render array and move it somewhere else, you can add MY_THEME_preprocess_page(&$variables) to template.php and the smartpaging render array is located inside the 'page' array, where depends on your particular theme regions it will probably be nested deep inside. So you can then move it to another variable and render it wherever you want with a custom page template.

ytsejam’s picture

Is there any way to display it with render($content[])? I tried both render($content['smart-paging-pager']) and render($content['smart-paging']) but no luck so far.

Rabuntu’s picture

Ok, small solution for display of pager on rendered page with fields.
My example:

<div class="art_2sp_bild"><?php print render($content['field_art_2sp_bild']); ?></div>
<div class="art_2sp_titel"><?php print $title; ?></div>
<div class="art_2sp_einleitung"><?php print render($content['field_art_2sp_einleitung']); ?></div>
<div class="art_2sp_text"><?php print render($content['field_art_2sp_text']);?></div>
<?php print render($content); ?>

The fields does render the content, so you can theme it. If you use additional <?php print render($content); ?> only the rest, also the pager, loading.

ytsejam’s picture

You mean to hide all the fields in the node field display, and then call them separately from the $content, while in it there's only the smart pager left? Sounds like a dirty hack to me, but I'll try it, thanks!

ytsejam’s picture

After giving it some thought, I managed to do it.

I made a var dump of $content and saw that it's actually called $content['smart_paging'], so I rendered it and it showed up correctly!

So now I can safely duplicate the pager both on top and below the content using a simple print render($content['smart_paging']);

Hope this is useful for somebody.

Rabuntu’s picture

Hello ytsejam,

Thx for your hard work to find out them. Your Solution is definitly cleaner. But my solution has also a certain logic. If i want to render and theming one Field and i want the rest untasted, is that the fastest solution.

<?php print render($content); ?> checked out which fields are printed and build the rest.

Nice, two solutions on one day. ;)

Unfortunately, it took almost 2 years, until someone found out that or has the maintainer this function installed secretly?

For you ytsejam
Merry Christmas

prashantmbhavsar’s picture

@ytsejam thanks a lot for your solution..its working...