Click PREV on first page of results????

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

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: [Jason] Click PREV on first page of results????

By mbodamer - July 25, 2012

sorry not to sound stupid but what do you mean i have to use my "MetaData" variable... I don't know which one that is.

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.