Display "homepages" data on listing page

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 1, 2011   (RSS)

By gversion - January 31, 2011

Hello,

I am trying to insert some information about the user that has created the listing using the "homepages" table.

So on the listing detail page I would like it to say:

"This listing was posted by [contact_name] from [organisation]..."

At the top of listingDetail.php I have the following code:

<?php

require_once "init.php";

list($listingsRecordRecords, $listingsRecordDetails) = getRecords(array(
'tableName' => 'listings',
'joinTable' => 'homepages',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$listingsRecord = @$listingsRecordRecords[0];


if (!$listingsRecord) { print "listingsRecord not found!"; exit; }

?>
<?php include "include_header.php"; ?>


I have then used the following code to try and insert the homepages data:

<tr>
<td>&nbsp;</td>
<td><b>This listed was posted by</b></td>
<td><a href="<?php echo $listingsRecord['homepages._link'] ?>"><?php echo $listingsRecord['homepages.contact_name'] ?> from <?php echo $listingsRecord['homepages.organisation'] ?></a> &nbsp;(<a href="listings.php?createdByUserNum=<?php echo $listingsRecord['createdByUserNum'] ?>">View all my listings</a>)<br />Tel: <?php echo $listingsRecord['homepages.phone'] ?></td>
</tr>



However, this is not working and the homepages text is not appearing.

I would be very grateful if you could help me figure out where I have gone wrong here.

Thank you,
Greg

Re: [gversion] Display "homepages" data on listing page

By Jason - February 1, 2011

Hi,

By default, getRecords will take care of a join to the accounts table for you, based on the createdByUserNum field.

for example, if you wanted the email from the account that created the record:

<?php echo $listingsRecord['createdBy.email'];?>

Greg, how are your homepages records and listings records being joined? If you use this code:

<?php showme($listingsRecord);?>

You'll be able to see everything that's being returned in your query. Is it returning what you expect?

Let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/