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
thanks,
jason
Re: [jdancisin] Prev/Next links on a Detail page?
The problem is; next or previous "what"?
[tongue]
Perch
Re: [Perchpole] Prev/Next links on a Detail page?
By zip222 - October 17, 2008
Re: [jdancisin] Prev/Next links on a Detail page?
By _kate_ - October 18, 2008 - edited: October 18, 2008
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
Re: [jdancisin] Prev/Next links on a Detail page?
By Dave - October 20, 2008
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'] ?>"> << <?php echo $prevRecord['title'] ?></a>
<?php endif; ?>
<?php if (@$nextRecord): ?>
<a href="<?php echo $nextRecord['_link'] ?>"><?php echo $nextRecord['title'] ?> >></a>
<?php endif; ?>
Hope that helps, let me know if you have any questions or problems with this.
interactivetools.com
Re: [Dave] Prev/Next links on a Detail page?
By zip222 - October 21, 2008 - edited: October 21, 2008
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
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).
interactivetools.com
Re: [Dave] Prev/Next links on a Detail page?
By dougdrury - June 24, 2009
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
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.
interactivetools.com