Display "No Records Found" Message

6 posts by 2 authors in: Forums > CMS Builder
Last Post: April 8, 2008   (RSS)

By kcallana - March 31, 2008

I want to have a photo pop into the spot if there is nothing filled in on cms fields, is this possible? Right now it doesn't even come up with the "No records Foun", what have I done wrong? Here is the page http://www.lorenzos.net it is the Holiday Specials Section in the lower right.



Thanks!

Re: [Dave] Display "No Records Found" Message

By kcallana - April 6, 2008

my code is

<?php endif ?>
<?php if (empty($record)): ?>
<!-- Display "No Records Found" Message -->
<img src="/images/holiday.png">
<?php endif ?>



not<?php if ($listDetails['noRecordsFound']): ?>
No records were found!<br/>
(but replace this with your image tag!)
<?php endif ?>



the page is www.lorenzos.net/index.php

Re: [kcallana] Display "No Records Found" Message

By Dave - April 6, 2008

Is Holiday Specials a single record or a list of pages? If it's a list of pages you may want to use the list viewer code.

If you could attach the file for index.php I could look at the viewer code and try and spot the problem.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Display "No Records Found" Message

By kcallana - April 7, 2008

holiday specials is a single page.

index.php is attached

thanks!
Attachments:

index_001.php 20K

Re: [kcallana] Display "No Records Found" Message

By Dave - April 8, 2008

Hi Kim,

Ok, so since the holiday specials section is a single-page section there will always be a record. So what we need to test is if one of your other fields is defined.

So we can use a PHP if statement for that and || which means "or". So I added this code:

<?php if ($record['title'] || $record['title_2'] || $record['title_3'] || $record['title_4']): ?>

... holiday specials are displayed here ...

<?php else: ?>
<img src="/images/holiday.png">
<?php endif ?>


Which basically means if any of those fields (title, title_2, title_3, title_4 isn't blank then show the holiday specials, otherwise they must all be blank so slow the holiday.png image which says check back another time.

You can see the page here (I didn't want to modify your original):
http://lorenzos.net/index2.php

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com