I am very much a PHP novice; I am occasionally able to modify PHP if I have really good directions on what to look for and what changes to make — but beyond that, I am anything but fluent in PHP.
However, in a website I’m working on, using Drupal modules, I have a PHP function that is outputting search results as a table. I want to add some CSS classes to some of the lines of output … but every time I try to put HTML into the PHP coding, I end up getting error messages, so I could use some help with this.
Here’s the code:
[code=php]
function theme_ulisting_search_result($record){
$thumbnails = ulistingapi_get_thumbnails($record->nid);
$destination = drupal_get_destination();
if (count($thumbnails) > 0){
$href = file_create_url($thumbnails[0]);
$image = l(“<img class=”list-view” src=”$href”>”,’node/’.$record->nid,
array(‘html’=>true,’query’=>$destination));
}else{
$image = “”;
};
if (trim($record->address) != ”){
$address = $record->address . ‘, ‘ . $record->city_name;
}else{
$address = $record->city_name;
}
$address = l($address, ‘node/’.$record->nid,array(‘query’=> $destination));
// icons
if ($record->bedroom > 0){
$icons .= ‘<div class=”ulisting-icon-bed”>’.$record->bedroom.'</div>’;
}
if($record->bathroom_full > 0){
$icons .= ‘<div class=”ulisting-icon-bathroom”>’.$record->bathroom_full.'</div>’;
}
$image .= ‘<div style=”clear:both”></div>’.$icons;
$currency = ($record->currency == ”)? variable_get(‘ulisting_currency’,’$’): $record->currency;
$node->vid = $record->nid;
$vid = variable_get(‘ulisting_property_type’, ”);
$terms = taxonomy_node_get_terms_by_vocabulary($node,$vid);
list($index,$property_type) = each($terms);
$vid = variable_get(‘ulisting_regions’, ”);
$terms = taxonomy_node_get_terms_by_vocabulary($node,$vid);
list($index,$region) = each($terms);
if ($region){
$region = $region->name;
};
$row = array(
array(‘data’ => $image),
array(‘data’ =>
$address.'<br />’.
$region.'<br />’.
$record->title,
‘valign’=>’top’,
),
array(‘data’ => $property_type->name,’valign’=>’top’),
array(‘data’ => $currency.number_format($record->price),
‘valign’=>’top’,
)
);
return $row;
}
I would like to take out the line break tags at the end of the [B]address[B]region[B]address[B]region[B]record->title
Any help or suggestions would be greatly appreciated.