Prev/Next links on a Detail page?

15 posts by 6 authors in: Forums > CMS Builder
Last Post: October 12, 2012   (RSS)

By zip222 - October 17, 2008

Is there a way to have prev/next page links on a Detail page. I know how to do this on a List page, but can't seem to figure out how to do it on a Detail page. Any help is appreciated.

thanks,
jason

Re: [jdancisin] Prev/Next links on a Detail page?

By Perchpole - October 17, 2008

Hi, Jason -



The problem is; next or previous "what"?

[tongue]

Perch

Re: [Perchpole] Prev/Next links on a Detail page?

By zip222 - October 17, 2008

I am looking for a way to insert links to the previous and next records. When you use the List page, metadata is available that makes this possible. I haven't been able to find a way to do the same thing when using a Detail page.

Re: [_kate_] Prev/Next links on a Detail page?

By zip222 - October 20, 2008

The List page approach is what I am currently using and it works ok but there is one specific issue I am having which is why I want to use the detail approach instead. Is there not a way to have prev/next links on a Detail page?

Re: [jdancisin] Prev/Next links on a Detail page?

By Dave - October 20, 2008

Hi jdancisin,

I wrote up some code for this a while ago. It may for for you. Try this, add this code to the bottom of step 1 in your detail viewer:

list($prevRecord, $nextRecord) = getPrevAndNextRecords(array(
'tableName' => 'news',
'recordNum' => getNumberFromEndOfUrl(),
));


Then add this where you want your prev/next links to go:

<?php if (@$prevRecord): ?>
<a href="<?php echo $prevRecord['_link'] ?>"> &lt;&lt; <?php echo $prevRecord['title'] ?></a>
<?php endif; ?>

<?php if (@$nextRecord): ?>
<a href="<?php echo $nextRecord['_link'] ?>"><?php echo $nextRecord['title'] ?> &gt;&gt;</a>
<?php endif; ?>


Hope that helps, let me know if you have any questions or problems with this.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Prev/Next links on a Detail page?

By zip222 - October 21, 2008 - edited: October 21, 2008

Thats exactly what I am looking for. One additional follow-up question...

Is there a variable for the first and last records? What I am trying to do is create a loop. So in the case where the record being viewed is the first record, the "previous" button would go to the first record. And if the record being viewed is the last record, the "next" button would go the first record. I found a way to do this with the List viewer but not with the Detail viewer.

I tried using "$firstRecord" and "$lastRecord" but not surprisingly, it didn't work. I looked through the viewer_functions and didn't see anything so I am guessing this doesn't exist at this point.

Re: [jdancisin] Prev/Next links on a Detail page?

By Dave - October 21, 2008

Hi jdancisin,

No, there's no functionality for that. I think I could add it pretty easily though to that function. If you like you can send me CMS and FTP login details, and the url to your page you're working on to dave@interactivetools.com and I'll see if I can make it work on your site. (Email, don't post login details to the forum).
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Prev/Next links on a Detail page?

By dougdrury - June 24, 2009

Dave,
Does this still work in 1.28? I tried this in 1.28 and keep getting a Notice:

Notice: Undefined variable: errors in /home/bigdesig/public_html/2009/cmsAdmin/lib/viewer_functions.php on line 1206

I know that I can quiet the notice, but was wondering if I just can edit the code?

Thanks,
Doug

Re: [dougdrury] Prev/Next links on a Detail page?

By Dave - June 24, 2009

Hi Doug,

That looks like an error message about the error messages. Try adding the lines in red to the top of that function:

// error checking
$errors = '';
if (!@$options['tableName']) { $errors .= "No 'tableName' value specified in options!<br/>\n"; }
if (!@$options['recordNum']) { $errors .= "No 'recordNum' value specified in options!<br/>\n"; }
if ($errors) { die(__FUNCTION__ . ": $errors"); }


Hope that helps! Let me know if that fixes it for you.
Dave Edis - Senior Developer
interactivetools.com