Featured Property Problem

11 posts by 3 authors in: Forums > CMS Builder
Last Post: October 24, 2011   (RSS)

By Wolf-E - October 10, 2011

Hi, I have a 3 column page for real estate, the left hand side column features latest properties by date, the right hand column features latest price movers (so far so good), however, I cannot get the (single) featured property in the centre column to load. In fact, when I added the centre column code (and attendant header code) the whole page failed to load, but when I strip out that code, it loads.

This is going to be a new index (php) page to replace the current (html) index page, with all the rest of the site going in a new folder (property_sales/). I'm about 95% there, just stalled on this featured property issue. I think a new pair of eyes is required, its probably something i'm just missing, like a '?'...thanks in advance.

(I've cut out most of the non essential code for the page (styles, text etc etc), its the 3 columns' content code thats the main issue.)






<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/sites/mywebsite.com/public_html/property_sales/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records
list($propertyRecords, $propertyMetaData) = getRecords(array(
'tableName' => 'property',
'perPage' => '3',
'orderBy' => 'date DESC, price',
'allowSearch' => '1',
));


// load latest movers records
list($moverspropertyRecords, $moverspropertyMetaData) = getRecords(array(
'tableName' => 'property',
'perPage' => '3',
'orderBy' => 'updatedDate DESC, new_price',
'allowSearch' => '0',
));

//load featured record
list($featuredpropertyRecords, $propertyMetaData) = getRecords(array(
'tableName' => 'property',
'where' => 'featured = 1',
'orderBy' => 'date'
'perPage' => '1',

));

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
</head>

<body>
<div id="wrap">

<!--left side content-->

<div id="leftside">
<h2>LATEST PROPERTIES:</h2>

<?php foreach ($propertyRecords as $record): ?>
<?php if (!$record['featured']): ?>
<div align="center">
<?php foreach ($record['property_images'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="140px" height="80px alt="" />
<?php break ?>
<?php endforeach ?></div>
<h2>&pound;<?php echo number_format($record['price']); ?></h2>

<h2> <?php echo $record['address'] ?><br/>
Listed: <?php echo date("D, M jS, Y ", strtotime($record['date'])) ?><br/>
Read Full Details:</h2> <a href="<?php echo $record['_link'] ?>"><?php echo $record['address'] ?> -> -></a><br/>
<hr style="color:#840000; background-color:#840000;height:1px;border:none;" />
<?php endforeach ?>



<?php if ($propertyMetaData['invalidPageNum']): ?>
Results page '<?php echo $propertyMetaData['page']?>' not found, <a href="<?php echo $propertyMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
<?php elseif (!$propertyRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->


</div>
</div>




<!--right side content-->

<div id="extras">
<h2>LATEST PRICE MOVERS</h2>
<?php foreach ($moverspropertyRecords as $record): ?>
<?php if (!$record['featured']): ?>
<h2>&pound;<?php echo number_format($record['price']); ?></h2>
<?php if($record['new_price']) : ?>
<h4> New Price! &pound;<?php echo number_format($record['new_price']) ?></h4>
<?php endif; ?>
<?php echo $record['address'] ?>
<p>&nbsp</p>

<!--display a single thumbnail image -->
<div align="center">
<?php foreach ($record['property_images'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="140px" height="80px alt="" />
<?php break ?>
<?php endforeach ?>
</div>
<!--end thumbnail area-->

<h5><a href="<?php echo $record['_link'] ?>">View Details -> -></a></h5>

<?php endforeach ?>

</div>


<!--main content area-->

<div id="content">

<h2>FEATURED PROPERTY</h2>

<?php foreach ($propertyRecords as $record): ?>
<?php if ($record['featured']:>
<h2>&pound;<?php echo number_format($record['price']); ?></h2>
<?php if($record['new_price']) : ?>
<h2> New Price!:&pound;<?php echo number_format($record['new_price']) ?></h2>
<?php endif; ?>
<h3> <?php echo $record['address'] ?></h3> (<?php echo $record['type'] ?>)<br/>
Featured: <?php echo $record['featured'] ?><br/>
Listed: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?> // Updated: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['updatedDate'])) ?><br/><br/>
<?php echo $record['teaser'] ?><br/>
Council Tax Band: <?php echo $record['council_tax_band'] ?> // Bedrooms: <?php echo $record['bedrooms'] ?> //

Read Full Details: <a href="<?php echo $record['_link'] ?>"><?php echo $record['address'] ?> -> -></a><br/>

<?php endforeach ?>

<?php if ($propertyMetaData['invalidPageNum']): ?>
Results page '<?php echo $propertyMetaData['page']?>' not found, <a href="<?php echo $propertyMetaData['firstPageLink'] ?>">start over &gt;&gt;</a>.<br/><br/>
<?php elseif (!$propertyRecords): ?>
No records were found!<br/><br/>
<?php endif ?>


<h3>You Are Viewing Property List Page: <?php echo $propertyMetaData['page'] ?>


&nbsp;&nbsp;

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

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

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



</div>
</div>
</body>
</html>

Re: [Wolf-E] Featured Property Problem

By Jason - October 11, 2011

Hi,

There are a number of syntax error in this code that is probably causing most of the problems you're experiencing.

The first one is where you are selecting your featured record. You're missing a comma after your "orderBy" option:

//load featured record
list($featuredpropertyRecords, $propertyMetaData) = getRecords(array(
'tableName' => 'property',
'where' => 'featured = 1',
'orderBy' => 'date',
'perPage' => '1',

));


In your code that outputs the records into your 3 columns, you have an if statement inside a foreach loop. However, you are not ending the if statement, so you'll need to add <?php endif ?> just before your <?php endforeach ?> statements. For example:

<h2>LATEST PROPERTIES:</h2>

<?php foreach ($propertyRecords as $record): ?>
<?php if (!$record['featured']): ?>
<div align="center">
<?php foreach ($record['property_images'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="140px" height="80px alt="" />
<?php break ?>
<?php endforeach ?></div>
<h2>&pound;<?php echo number_format($record['price']); ?></h2>

<h2> <?php echo $record['address'] ?><br/>
Listed: <?php echo date("D, M jS, Y ", strtotime($record['date'])) ?><br/>
Read Full Details:</h2> <a href="<?php echo $record['_link'] ?>"><?php echo $record['address'] ?> -> -></a><br/>
<hr style="color:#840000; background-color:#840000;height:1px;border:none;" />
<?php endif ?>
<?php endforeach ?>


Finally, in your if statement checking if a record is "featured" you're missing a end bracket and a "?":

<?php if ($record['featured']): ?>

Another thing I noticed is that you select records into the variable $featuredpropertyRecords, but this variable is never used in the rest of the script. It may be easier to have 3 different record sets (one for each column) instead of looping through all your properties 3 times and using if statements.

Hope this helps get you started.
---------------------------------------------------
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] Featured Property Problem

By Wolf-E - October 12, 2011

Hi Jason

I had a feeling i'd missed a comma or similar, thanks for your help. However, after making the alterations, i'm still not getting the page to display at all. Could you expand a little on what you meant by not using the variable in the script, ie; where and which bit please? I'm a bit lost with this page at present.

Re: [Wolf-E] Featured Property Problem

By Jason - October 12, 2011

Hi,

Near the top of the page you have this code:

//load featured record
list($featuredpropertyRecords, $propertyMetaData) = getRecords(array(
'tableName' => 'property',
'where' => 'featured = 1',
'orderBy' => 'date',
'perPage' => '1',

));


This gets 1 record from the property section where featured=1 and puts it in the variable $featuredpropertyRecords. However, this variable isn't used anywhere else in the script. This probably isn't causing any problems, but from an optimization standpoint, it's usually a good idea to get rid of any variables/database calls that aren't needed.

When you load your page, do you get just a blank screen? If so, there are probably still errors on the page and your server is suppressing the messages. If you want to attach your latest version of the file, I can take a look and see if anything jumps out.

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: [Wolf-E] Featured Property Problem

By Jason - October 13, 2011

Hi,

It looks like you're missing an "endif" statement in your block where you're outputting your featured property. Try this (change in blue):

<h2>FEATURED PROPERTY</h2>

<?php foreach ($featuredpropertyRecords as $record): ?>
<?php if ($record['featured']): ?>
<h2>&pound;<?php echo number_format($record['price']); ?></h2>
<?php if($record['new_price']) : ?>
<h2> New Price!:&pound;<?php echo number_format($record['new_price']) ?></h2>
<?php endif; ?>
<h3> <?php echo $record['address'] ?></h3> (<?php echo $record['type'] ?>)<br/>
Featured: <?php echo $record['featured'] ?><br/>
Listed: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['date'])) ?> // Updated: <?php echo date("D, M jS, Y g:i:s a", strtotime($record['updatedDate'])) ?><br/><br/>
<?php echo $record['teaser'] ?><br/>
Council Tax Band: <?php echo $record['council_tax_band'] ?> // Bedrooms: <?php echo $record['bedrooms'] ?> //

Read Full Details: <a href="<?php echo $record['_link'] ?>"><?php echo $record['address'] ?> -> -></a><br/>
<?php endif ?>
<?php endforeach ?>

---------------------------------------------------
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] Featured Property Problem

By Wolf-E - October 19, 2011

Hi Jason

That fixed it. Thanks for your patience! Guess I need a holiday, can't spot the wood for the trees. [cool]

Re: [Jason] Featured Property Problem

By Wolf-E - October 24, 2011

HI again Jason. Just one last thing, the files and cms and everything reside in the folder: property_sales/ i'm having trouble getting the index.php page links to connect with the detail-page.php, list-page.php inside that folder. The current path at the header is:

<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/sites/acmspropertycentre.com/public_html/property_sales/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

?>

Should I try and change the path to something like:

$dirsToCheck = array('/home/sites/acmspropertycentre.com/public_html/property_sales/cmsAdmin/lib/viewer_functions.php";);
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

However, i tried that and a few other permutations but without success. Thanks in advance.

Re: [Wolf-E] Featured Property Problem

By Jason - October 24, 2011

Hi,

That code in the header is the code that attempts to connect to CMS Builder. If it fails, the page will stop and display a message saying "Couldn't load viewer library, check filepath in sourcecode".

Are you getting that message? If not, then that part of the code is working correctly.

So, is the problem you're experiencing is trying to link from list-page.php to detail-page.php? Are these files in the same folder? Could you provide a link to a page that demonstrates the problem?

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: [Wolf-E] Featured Property Problem

By Dave - October 24, 2011

Hi Wolf-E,

Also, can you update your forum email? We're getting bounces on the reply notifications that are being sent.

You can update your email here:
http://www.interactivetools.com/iforum/gforum.cgi?do=user_profile_basic

Thanks!
Dave Edis - Senior Developer
interactivetools.com