Prev/Next Links on List Page

8 posts by 2 authors in: Forums > CMS Builder
Last Post: January 5, 2011   (RSS)

By design9 - December 29, 2010 - edited: March 21, 2011

Hello,
I need some help in putting some prev/next record links on a list page. I have seen the posts that show this for a details page but that code doesn't seem to work for my list pages. I have it set to show the first 25 listings on the page and then I want to include the prev/next links to show additional listings. My information is set up using a multi-viewer that is called 'mag_locater'.

Thank you,

Re: [chris] Prev/Next Links on List Page

Thanks Chris! That did the trick however on one of my results pages, it is not working. This page has the geocoder plugin code on it so I am not sure if something on there is causing it not to work properly because on my other results page, it works great. Here is my page where it works fine that uses part of the geocoder plugin:

http://www.piedmontparent.com/publications/findmagazine/results.php

Here is the page that contains additional geocoder plugin (also contains distance search coding):
http://www.piedmontparent.com/publications/findmagazine/distanceresults.php
This page doesn't work on these areas:
1. the area that shows how many records 1-4of 8.

2. I have 8 listings in the database so I set the code to show 4 per page to test the prev/next links:
list($mag_locaterRecords, $mag_locaterMetaData) = getRecords(array(
'tableName' => 'mag_locater',
'perPage' => 4,
));
But when I use the search to get to this page, it shows all 8 records and the prev/next doesn't work as well as the showing 1-4of 8.

Here is the search page:
http://www.piedmontparent.com/publications/findmagazine/search.php

The top search goes to the results.php page and that works fine. The distance search is the one not working and it goes to the distanceresults.php page. I have included that page of code as an attachment as well if you need to look at it.

Thanks!
April
Attachments:

distanceresults.php 37K

Re: [apdance9] Prev/Next Links on List Page

By Chris - December 30, 2010

Hi April,

You'll need to add the perPage option to this getRecords call as well:

// get records
$addressRecords = array();
if ($myLat && $myLng) {
$maxDist = floatval(@$_REQUEST['maxDistance']);
list($mag_locaterRecords, $mag_locaterMetaData) = getRecords(array(
'tableName' => 'mag_locater',
'addSelectExpr' => geocoder_getSelectExprForDistance($myLat, $myLng, '_distance', $kmOrMiles), // adds '_distance' field to output records
'where' => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles), // optimization: remove results outside of minimum bounding rectangle
'having' => "_distance <= " . $maxDist, // only show results within max distance
'orderBy' => 'ISNULL(_distance), _distance', // sort nearest records first -and- unknown or undefined distances last
'perPage' => 4,
));
}


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Prev/Next Links on List Page

By design9 - January 3, 2011

Hi Chris,
Thanks so much...that did the trick. The only part that is not working now is the speech balloon in the google maps. I have the coding on the page to display the information in the balloon when you click on a pointer on map but it takes you straight to the details page without showing the speech balloon. Is there anything else that is missing that would cause this not to work on this page? The page source was attached above and here is the page:
http://www.piedmontparent.com/publications/findmagazine/distanceresults.php

Thanks!
April

Re: [apdance9] Prev/Next Links on List Page

By Chris - January 4, 2011

Hi April,

You'll need to add the "STEP4" code from sample_map_multi.php to your page to get infowindows (aka speech balloons) working:

<!-- STEP4: Map with multiple addresses: Set the popup window content, rename $myrecords if needed -->
<div id="marker_details" style="display: none;">
<?php foreach ($myRecords as $record): ?>

<?php // marker_infowindow_### is the content displayed in the info-window on click ?>
<div id="marker_infowindow_<?php echo $record['num']; ?>">
<h3><?php echo htmlspecialchars( @$record['address']); ?></h3>
Add any extra content you like here...<br/>
<a href="<?php echo $record['_link']; ?>">details</a>
</div>

<?php endforeach ?>
</div>
<!-- STEP4: Map with multiple addresses -->


You can add this anywhere in the <body/> of your page.

I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Prev/Next Links on List Page

By design9 - January 5, 2011

Chris,

I do have this coding already on my page and the [font "Verdana"]infowindows (aka speech balloons) still[/#000000] doesn't work.

Any other ideas of what could be wrong?

April

Re: [apdance9] Prev/Next Links on List Page

By Chris - January 5, 2011

Hi April,

Looking at your attached source code, I see that the <div id="marker_details"/> is inside of an <?php if (!$hasAddresses): ?>. You'll need to move it outside of that IF block, which is preventing it from being displayed when there are addresses to show.

You can check to make sure it's getting output by viewing source (through your browser) and searching for "marker_details".

I hope this helps. Please let me know if you have any questions.
All the best,
Chris