PDA

View Full Version : Todays Listing



ican
06-19-2004, 08:25 PM
I wanted a mod to show Today's Listings so I used Mick's
Thank you Mick ...
FeaturedListingsHorizontalInfo to make one.

I thought I should share it so here we go.


1) Place in style.php
*** Note File edited on the 20th June 2004 ***** If you downloaded this mod before the 20th June 2004, please re-download and follow new instructions ****


function todays($num_of_listings)
{
// shows the images connected to a given image

global $conn, $lang, $config, $style;
// grab the images
$listingID = make_db_extra_safe($listingID);
$today = date('Y-m-d');
//$seed=srand((double) microtime()*1000000);
$sql = "SELECT ID, Title, creation_date FROM " . $config[table_prefix] . "listingsDB WHERE (creation_date = '.$today.') ORDER BY RAND()";
$recordSet = $conn->SelectLimit($sql, $num_of_listings, 0 );
if ($recordSet === false)
{
log_error($sql);
}

$returned_num_listings = $recordSet->RecordCount();
if ($returned_num_listings > 0)
echo "<b><h3>Today's Listings($returned_num_listings)</h3></b>";
{

print "<table border='0' width=\"95%\" cellpadding=\"1\" cellspacing=\"1\" align='center'>";
$numcols = 5;
$count = 1;
print "<tr>";

while (!$recordSet->EOF)
{
$Title = make_db_unsafe ($recordSet->fields[Title]);
$ID = make_db_unsafe ($recordSet->fields[ID]);
// GRAB THE LISTINGS IMAGE
$sql2 = "SELECT thumb_file_name FROM " . $config[table_prefix] . "listingsImages WHERE listing_id = $ID ORDER BY ID";
$recordSet2 = $conn->SelectLimit($sql2, 1, 0);
$sql3 = "SELECT field_name, field_value FROM " . $config[table_prefix] . "listingsDBElements WHERE (listing_id = $ID) ";
$recordSet3 = $conn->Execute($sql3);
if ($recordSet2 === false)
{
log_error($sql2);
}
$num_images = $recordSet2->RecordCount();

$thumb_file_name = make_db_unsafe ($recordSet2->fields[thumb_file_name]);

if ($thumb_file_name == "")
{
$thumb_file_name = "nophoto_big.jpg";

} // end if

// ******* Fix ***********
while (!$recordSet3->EOF) {
if ($recordSet3->fields[field_name] == "baths") { $baths = $recordSet3->fields[field_value]; };
if ($recordSet3->fields[field_name] == "beds") { $beds = $recordSet3->fields[field_value]; };
if ($recordSet3->fields[field_name] == "price") { $price = $recordSet3->fields[field_value]; };
$priceformatted = international_num_format($price);
$recordSet3->MoveNext();
}
// ****** End Fix ********
while (!$recordSet2->EOF)
{
// $thumb_file_name = make_db_unsafe ($recordSet2->fields[thumb_file_name]);
if ($thumb_file_name != "")
{
// GOTTA GRAB THE IMAGE SIZE
$imagedata = GetImageSize("$config[listings_upload_path]/$thumb_file_name");
$imagewidth = $imagedata[0];
$imageheight = $imagedata[1];
$shrinkage = $config[thumbnail_width]/$imagewidth;
$displaywidth = $imagewidth * $shrinkage;
$displayheight = $imageheight * $shrinkage;
} // end if
$recordSet2->MoveNext();
} // end while
$recordSet->MoveNext();
if ($count % $numcols ==0)
{
print "<td width align='left'><a href='/listingview.php?listingID=$ID'><b>$Title</b><br>";
print "<div align=\"left\"><img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"70\" width=\"100\" alt=\"$lang[click_to_learn_more]\" border=1></a><br>";
Print("<b><font size=\"1\">".$beds." Bed Rooms/".$baths." Bath Rooms</font></b><br>");
Print("<font color=\"darkred\"><b>".money_formats($priceformatted)."</b><br></font>");
echo "</div></td></tr><tr>";
}
else
{
print "<td align=\"left\"><a href=\"/listingview.php?listingID=$ID\"><b>$Title</b><br>";
print "<div align=\"left\"><img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"70\" width=\"100\" alt=\"$lang[click_to_learn_more]\" border=1></a><br>";
Print("<b><font size=\"1\">".$beds." Bed Rooms/".$baths." Bath Rooms</font></b><br>");
Print("<font color=\"darkred\"><b>".money_formats($priceformatted)."</b><br></font>");
echo "</div></td>";
} //end if
$count++;
} // end while
print "</tr></table>";
} //end if
} // end function todays


2) Place in any file you want to display it in (can even make a new file called todays.php)

******* File edited **** I forgot that I have found this bug in the featuredlistinginfo both horizantal and vertical that will not show when there is no photo so I fixed it. **********

**** please copy the attached file nophoto_big.jpg to your images/listing_photos/ folder. that will fix that issue.


<br><?php todays(8) ?>


see it here http://www.windsorrealty.ca/index.php

If there was no listing added the day you go to this link, it will not show anything (Funny, that means that the script actually works) so you just have to try it yourself and add a new listing are two.


Enjoy..[/b]

luis
06-19-2004, 11:08 PM
Congrats on a great mod.

All works accept when we use a nophoto situation........listing shows funny(nophoto pic to the left the rest in another column)....Any Ideas :!:

Regards

ican
06-20-2004, 03:44 AM
Congrats on a great mod.

All works accept when we use a nophoto situation........listing shows funny(nophoto pic to the left the rest in another column)....Any Ideas :!:

Regards

Thanks, I forgot about the bug I found in the featured listing that will not show featured listing that have no photo. I edited the original post.

Thanks for feed back

new fix demo here (shows only if new listing on that day, photo or no photo).

http://www.windsorrealty.ca/index.php

luis
06-20-2004, 03:41 PM
Perfect My Friend :lol:

Congrats
luis

luis
06-20-2004, 05:06 PM
I would just add the is active bit like so:

$sql = "SELECT ID, Title, mls, creation_date FROM " . $config[table_prefix] . "listingsDB WHERE (creation_date = '.$today.') AND (active = 'yes') ORDER BY RAND()";


Regards
Luis

ican
06-20-2004, 09:08 PM
I would just add the is active bit like so:

$sql = "SELECT ID, Title, mls, creation_date FROM " . $config[table_prefix] . "listingsDB WHERE (creation_date = '.$today.') AND (active = 'yes') ORDER BY RAND()";


Regards
Luis

You are welcome.. Glad I could help.

bozzdogg
06-23-2004, 04:21 PM
i tried it, can`t get it to work, must be missing something. error says call to undefined funtion

ican
06-23-2004, 05:06 PM
i tried it, can`t get it to work, must be missing something. error says call to undefined funtion

Did you add the code to style.php and then


<br><?php todays&#40;8&#41; ?> to the file you want it to show in.?

bozzdogg
06-24-2004, 06:14 PM
yes, i did. i just changed servers, will try again. thxs

bozzdogg
06-24-2004, 06:31 PM
changing servers not only fixed this problem, it fixed the other one i was asking about in another part of the help forum. go figure thx