Click PREV on first page of results????

10 posts by 2 authors in: Forums > CMS Builder
Last Post: July 25, 2012   (RSS)

By mbodamer - July 25, 2012

Hi,
I recently migrated a client from LM to CMSB. On the old LM when you did a search and it showed page 1-9 the < PREV and NEXT > arrows are both linked from the first result page. Meaning if the results are sorted by highest price, and I have 10 pages of listings, I can click < PREV on the first result page to go to the LAST page instead of clicking NEXT > 9 times.

In CMSB I am trying to mimic the same function but the < PREV doesn't link to anything on the first result page.

Here is the examples:

LM - http://www.abacoestateservices.com/cgi-bin/listings/exec/search.cgi?search=1&perpage=10&sort_order=5%2C123%2Creverse&marknew=7&lfield5_min=&lfield5_max=&lfield9_min=&lfield9_max=&lfield10_min=&lfield10_max=&lfield8_keyword=Condominium&lfield3_keyword=&search=++Search+Listings++&pagenum=9&pagenum=1&pagenum=9&pagenum=1

CMSB - http://www.abacoestateservices.com/bahamasrealestate/listings.php?mls_match=&price_min=0&price_max=&bedrooms_min=&bedrooms_max=&bathrooms_min=&bathrooms_max=&property_type=Condominium&location=&search=++Search+Listings++&page=1

The other option would be to have sort by buttons on the top of the results like price (high to low, low to high) or if it finds 10 pages of listings maybe have < PREV 1 2 3 4 5 NEXT > with each page being clickable so you can jump around...

Any suggestions?
Thanks

Re: [mbodamer] Click PREV on first page of results????

By Jason - July 25, 2012

Hi,

The default code generator code only makes next and previous a link if there is a next or previous page available. However, there are firstPageLink and lastPageLink that is returned and you can use this to get the functionality you're talking about.

Here's an example of what that code would look like:

<!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
<?php if ($listingsMetaData['prevPage']): ?>
<a href="<?php echo $listingsMetaData['prevPageLink'] ?>">&lt;&lt; prev</a>
<?php else: ?>
<a href = "<?php echo $listingsMetaData['lastPageLink'];?>">&lt;&lt; prev</a>
<?php endif ?>

- page <?php echo $listingsMetaData['page'] ?> of <?php echo $listingsMetaData['totalPages'] ?> -

<?php if ($listingsMetaData['nextPage']): ?>
<a href="<?php echo $listingsMetaData['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
<a href = "<?php echo $listingsMetaData['firstPageLink'];?>">next &gt;&gt;</a>
<?php endif ?>
<!-- /STEP3: Display Page Links -->


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Click PREV on first page of results????

By mbodamer - July 25, 2012

thank but I get an error with this code:

Notice: Undefined variable: listingsMetaData in /home/abestate/public_html/bahamasrealestate/listings.php on line 116 << prev - page Notice: Undefined variable: listingsMetaData in /home/abestate/public_html/bahamasrealestate/listings.php on line 122 of Notice: Undefined variable: listingsMetaData in /home/abestate/public_html/bahamasrealestate/listings.php on line 122 - Notice: Undefined variable: listingsMetaData in /home/abestate/public_html/bahamasrealestate/listings.php on line 124 next >>

the links that are working already have $listingDetails instead of $listingMetaData

Re: [mbodamer] Click PREV on first page of results????

By Jason - July 25, 2012

Hi,

The code I posted was only an example. You'll need to change variable names to match what you are using on your page. You'll want to use your "MetaData" variable to get this to work however.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [mbodamer] Click PREV on first page of results????

By Jason - July 25, 2012

No worries. :) If you can attach the .php page you're working with I can show you which variable you'll need.

Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Click PREV on first page of results????

By mbodamer - July 25, 2012

Here you go... THANKS!
Attachments:

listings_003.php 5K

Re: [mbodamer] Click PREV on first page of results????

By Jason - July 25, 2012

Hi,

Okay, I see the confusion. :) The variable you have called $listingDetail would normally be called $listingMetaData by the code generator. But the information is still there, so it's no problem.

Give this a try:

<!-- STEP3: Display Page Links (Paste anywhere below "Load Record List") -->
<?php if ($listingDetails['prevPage']): ?>
<a href="<?php echo $listingDetails['prevPageLink'] ?>">&lt;&lt; prev</a>
<?php else: ?>
<a href = "<?php echo $listingDetails['lastPageLink'];?>">&lt;&lt; prev</a>
<?php endif ?>

- page <?php echo $listingDetails['page'] ?> of <?php echo $listingDetails['totalPages'] ?> -

<?php if ($listingDetails['nextPage']): ?>
<a href="<?php echo $listingDetails['nextPageLink'] ?>">next &gt;&gt;</a>
<?php else: ?>
<a href = "<?php echo $listingDetails['firstPageLink'];?>">next &gt;&gt;</a>
<?php endif ?>
<!-- /STEP3: Display Page Links -->



Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [mbodamer] Click PREV on first page of results????

By mbodamer - July 25, 2012

nevermind I got it working... thanks your code did the trick.