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?

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: [jdancisin] Prev/Next links on a Detail page?

By _kate_ - October 18, 2008 - edited: October 18, 2008

Hi jdancisin,
How I got around this on a website recently was >
I generated the List Page code, selected that I wanted to "show the first 1 record only" and used it as a detail page.

The list page code will generate all the fields so you can then use it like a detail page but have the next/previous links on the page. I did make a point of deleting the "_link" field.

If you link directly to the pages from your website navigation, you will need to adjust the links accordingly e.g. my page was called "playgrounds.php" but to link to each product I needed to use the following >
playgrounds.php?page=1, playgrounds.php?page=2 etc
You can figure out what these are by looking at the next/previous links.

I hope that helps. If that isn't going to work for you cause of how you have your pages setup or you have any further questions please don't hesitate to ask :)

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: [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