require( "admin/config.inc.php" );
// define the templates for general layout and the page content
$tpl->define(array(
"common" => "common.tpl.html",
"body" => "listing2.tpl.html",
"testimonials" => "listing3.tpl.html"
));
// type should come through GET
switch( $type ){
case 'progress': $typeText = 'Work in Progress'; break;
case 'finished': $typeText = 'Finished Projects'; break;
case 'testimonials': $typeText = 'Testimonials'; break;
default: $type='progress'; $typeText = 'Work in Progress'; break;
}
// assign initial values
$tpl->assign(array(
"TOP_NAVIGATION" => "Home :: $typeText"
));
if ($typeText == 'Testimonials'){
$tpl->define_dynamic( "row", "testimonials" );
$sql = "SELECT *
FROM testimonials
WHERE visibility=1
ORDER BY ".$testimonials_order.";";
$result = mysql_query( $sql );
while( $row = mysql_fetch_object($result) ){
$tpl->assign(array(
"PEOPLE_PHOTO" => "
",
"PROPERTY_LINK" => $row->url,
"PROPERTY_PHOTO" => "
",
"TEXT" => nl2br($row->text) ,
"URL" => $row->url,
"LINK" => '>> Click to see finished project'
));
$tpl->parse( ROWS, ".row" );
}
$tpl->parse( "BODY", "testimonials" );
}
else{
$tpl->define_dynamic( "row", "body" );
// get all the visible properties for this type
$sql = "SELECT id, name, descr, show2
FROM properties
WHERE type='$type' AND display='visible'
ORDER BY time_stamp DESC";
$result = mysql_query( $sql );
while( $row = mysql_fetch_object($result) ){
$id = $row->id;
// get the main photo for this property
$sql = "SELECT id, info FROM photos WHERE property_id='$id' ORDER BY pic_order LIMIT 2";
$phresult = mysql_query( $sql );
$num_rows = mysql_num_rows($phresult);
if( $num_rows == 0 ){
$tpl->assign(array(
"PROPERTY_PHOTO1" => " ",
"PHOTO_1_info" => " ",
"PROPERTY_PHOTO2" => " ",
"PHOTO_2_info" => " ",
));
}
if( $num_rows > 0 ){
$phrow1 = mysql_fetch_object($phresult);
$photo_id_1 = $phrow1->id;
if ($phrow1->info=="") $photo_id_1_info = " ";
else $photo_id_1_info = $phrow1->info;
$tpl->assign(array(
"PROPERTY_PHOTO1" => "
",
"PHOTO_1_info" => "$photo_id_1_info",
));
}
if (($num_rows > 1) && ($row->show2 == "true")){
$phrow2 = mysql_fetch_object($phresult);
$photo_id_2 = $phrow2->id;
if ($phrow2->info=="") $photo_id_2_info = " ";
else $photo_id_2_info = $phrow2->info;
$tpl->assign(array(
"PROPERTY_PHOTO2" => "
",
"PHOTO_2_info" => "$photo_id_2_info"
));
}
else{
$tpl->assign(array(
"PROPERTY_PHOTO2" => " ",
"PHOTO_2_info" => " ",
));
}
$tpl->assign(array(
"PROPERTY_LINK" => "spec.php?id=$id",
"PROPERTY_NAME" => $row->name,
"PROPERTY_DESCR" => nl2br($row->descr)
));
$tpl->parse( ROWS, ".row" );
}
$tpl->parse( "BODY", "body" );
}
// parse the contents and generate the web page
$tpl->parse( "MAIN", "common" );
$tpl->FastPrint();
?>