Possibly a 'sortby' error?
3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 29, 2011 (RSS)
By Wolf-E - July 22, 2011 - edited: July 22, 2011
Hi. I have a real estate site i'm building with CMS, mostly okay (detail pages/fulllist page show fine). I have 3 columns; left is for displaying 'new properties', the right column for displaying 'latest price movers'. (the main center column is for text and such like)
But, when i add a new (test) listing to the 'price movers' category, it shows up in both columns, instead of just the 'price movers' column alone. I've gone through the forums and experimented a bit with the code, but so far no luck. Here's the code:
(above <header> as per usual)
// load latest movers records
list($moverspropertyRecords, $moverspropertyMetaData) = getRecords(array(
'tableName' => 'property',
'perPage' => '6',
'orderBy' => 'updatedDate DESC, new_price',
'allowSearch' => '0',
));
// load records
list($propertyRecords, $propertyMetaData) = getRecords(array(
'tableName' => 'property',
'perPage' => '6',
'orderBy' => 'date DESC',
'allowSearch' => '0',
));
and in the <body>
<!--left hand column listings new-->
<?php foreach ($propertyRecords as $record): ?>
<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>£<?php echo number_format($record['price']); ?></h2>
<h3> <?php echo $record['address'] ?></h3> <br/>
Listed: <?php echo date("D, M jS, Y ", strtotime($record['date'])) ?><br/>
Read Full Details: <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 >></a>.<br/><br/>
<?php elseif (!$propertyRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /end left hand column listings new -->
<!--right side content price movers-->
<?php foreach ($moverspropertyRecords as $record): ?>
<h2>£<?php echo number_format($record['price']); ?></h2>
<?php if($record['new_price']) : ?>
<h4> New Price! £<?php echo number_format($record['new_price']) ?></h4>
<?php endif; ?>
<?php echo $record['address'] ?>
<p> </p>
<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 ?>
Any ideas or thoughts to make this work welcome!
But, when i add a new (test) listing to the 'price movers' category, it shows up in both columns, instead of just the 'price movers' column alone. I've gone through the forums and experimented a bit with the code, but so far no luck. Here's the code:
(above <header> as per usual)
// load latest movers records
list($moverspropertyRecords, $moverspropertyMetaData) = getRecords(array(
'tableName' => 'property',
'perPage' => '6',
'orderBy' => 'updatedDate DESC, new_price',
'allowSearch' => '0',
));
// load records
list($propertyRecords, $propertyMetaData) = getRecords(array(
'tableName' => 'property',
'perPage' => '6',
'orderBy' => 'date DESC',
'allowSearch' => '0',
));
and in the <body>
<!--left hand column listings new-->
<?php foreach ($propertyRecords as $record): ?>
<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>£<?php echo number_format($record['price']); ?></h2>
<h3> <?php echo $record['address'] ?></h3> <br/>
Listed: <?php echo date("D, M jS, Y ", strtotime($record['date'])) ?><br/>
Read Full Details: <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 >></a>.<br/><br/>
<?php elseif (!$propertyRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /end left hand column listings new -->
<!--right side content price movers-->
<?php foreach ($moverspropertyRecords as $record): ?>
<h2>£<?php echo number_format($record['price']); ?></h2>
<?php if($record['new_price']) : ?>
<h4> New Price! £<?php echo number_format($record['new_price']) ?></h4>
<?php endif; ?>
<?php echo $record['address'] ?>
<p> </p>
<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 ?>
Any ideas or thoughts to make this work welcome!
Re: [Wolf-E] Possibly a 'sortby' error?
By Jason - July 22, 2011
Hi,
How are you storing a category for price movers? Since the only difference between the two queries is how you're sorting the records, is is entirely possible that the same record would appear in both columns.
A good way to address this would be to add a check box called "price_mover" and check this for records you want to appear in the price movers column but not the new properties column. You can then structure your queries like this:
Hope this helps get you started.
How are you storing a category for price movers? Since the only difference between the two queries is how you're sorting the records, is is entirely possible that the same record would appear in both columns.
A good way to address this would be to add a check box called "price_mover" and check this for records you want to appear in the price movers column but not the new properties column. You can then structure your queries like this:
// load latest movers records
list($moverspropertyRecords, $moverspropertyMetaData) = getRecords(array(
'tableName' => 'property',
'perPage' => '6',
'orderBy' => 'updatedDate DESC, new_price',
'where' => "price_movers = 1",
'allowSearch' => '0',
));
// load records
list($propertyRecords, $propertyMetaData) = getRecords(array(
'tableName' => 'property',
'perPage' => '6',
'orderBy' => 'date DESC',
'where' => "price_movers = 0",
'allowSearch' => '0',
));
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/
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] Possibly a 'sortby' error?
By Wolf-E - July 29, 2011
Thanks Jason.
That worked well and the sort now looks a lot tidier. Appreciate the advice.
Cheers ~ Wolf-E
[:)]
That worked well and the sort now looks a lot tidier. Appreciate the advice.
Cheers ~ Wolf-E
[:)]