hiding next and previous buttons when under perPage number

5 posts by 2 authors in: Forums > CMS Builder
Last Post: July 21, 2010   (RSS)

By petejdg - July 6, 2010 - edited: July 6, 2010

I have my perPage record count set at 12 and would like to hide the "next" and "previous" navigation buttons unless I have 13 or more records in my db. Right now I have only 6 and don't want those to show since they are not needed. Not too familiar with php coding.
Attachments:

news_002.php 18K

Re: [petejdg] hiding next and previous buttons when under perPage number

By Jason - July 6, 2010

Hi,

This won't be hard to do. If you could attach the .php file you're working with, I'll be able to show you exactly where the code should go.

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] hiding next and previous buttons when under perPage number

By petejdg - July 20, 2010

Did you ever get a chance to look at my file?

Re: [petejdg] hiding next and previous buttons when under perPage number

By Jason - July 20, 2010

Hi,

Sorry for the delay.

What you need to do is to check to see how many records have been returned. If it's greater than 12, you display the next/previous links.

Try replacing the code that displays these links with this:

<?php if($newsMetaData['totalRecords']>12): ?>
<?php if ($newsMetaData['prevPage']): ?>
<a href="<?php echo $newsMetaData['prevPageLink'] ?>"><img src="../_images/arrow-prev-yellow.gif" alt="previous" width="19" height="19" border="0" /></a>
<?php else: ?>
<img src="../_images/arrow-prev-gray.gif" width="19" height="19" />
<?php endif ?></td>
<td align="center" valign="middle"><?php echo $newsMetaData['page'] ?> of <?php echo $newsMetaData['totalPages'] ?></td>
<td align="center" valign="middle"> <?php if ($newsMetaData['nextPage']): ?>
<a href="<?php echo $newsMetaData['nextPageLink'] ?>"><img src="../_images/arrow-next-yellow.gif" alt="next" width="19" height="19" border="0" /></a>
<?php else: ?>
<img src="../_images/arrow-next-gray.gif" width="19" height="19" alt="next" /></p>
<?php endif ?>
<?php endif ?>


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/