Featured Property Problem

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

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 Wolf-E - October 13, 2011 - edited: October 13, 2011

Hi Jason/ Yes, i'm still getting a blank page, however, if I remove all code refering to the featured property section, the page loads fine. So that might help narrow it down a bit? I've attached the file (minus style elements). Thanks for your help.
Attachments:

index.txt 5K

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