When on the last (or first) node of the chosen content type the $last (and $first) variables do not display/exist.

Simple add the following to your the flippy.tpl.php file and note how on the first and last node the nid does not display:

<h1><?php print $current['nid']; ?></h1>
<h1><?php print $first['nid']; ?></h1>
<h1><?php print $last['nid']; ?></h1>

This prevents us from writing logic that would loop through the nodes (send the node back to the first page when the current node is the last node):

<?php if ($current['nid'] == $last['nid']): ?>
	<div id="nextPager"><a href="/node/<?php print $first['nid']; ?>"></a></div> 
<?php else: ?>
	<div id="nextPager"><a href="/node/<?php print $next['nid']; ?>"></a></div> 
<?php endif; ?>
CommentFileSizeAuthor
#4 flippy-loop-1821322.patch7.03 KBfreddybushboy

Comments

hoff331’s picture

the workaround is:

<?php if (!empty($last_link)): ?>
    <div id="nextPager"><?php print $next_link; ?></div> 
<?php else: ?>
	<div id="nextPager"><?php print $first_link; ?></div>
<?php endif; ?> 
rli’s picture

Category: bug » feature
freddybushboy’s picture

If you want to avoid editing the tpl file or having a copy of it in your theme, you can do this quite simply with the template_preprocess_flippy function in your theme's template.php file:

/**
 * Implements template_preprocess_flippy();
 */
function THEMENAME_preprocess_flippy(&$vars) {
  // Make flippy loop through the nodes.
  if (!isset($vars['last'])) {
    $vars['links']['next']['href'] = 'node/' . $vars['first']['nid'];
  }
  if (!isset($vars['first'])) {
    $vars['links']['prev']['href'] = 'node/' . $vars['last']['nid'];
  }
}
freddybushboy’s picture

StatusFileSize
new7.03 KB

I also made a patch which adds the loop checkbox if anyone is interested :)

rli’s picture

Status: Active » Fixed

Thanks Freddy.

Just committed it to dev.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

grammatical fixes