I am using the phpMyDirectory script for a business directory site I am working on.
Here's a link to my site.
On my homepage, I have a "recent reviews" box that shows the most recent reviews that have been left by site visitors. My php script uses limit_words to truncate reviews that are longer than a specified length. I can't get it to work correctly. Can somebody help?
Here's the php:
PHP Code:
$sidebox_latestreviews = & new PMDTemplate(PMDROOT.TEMPLATE_PATH.'/blocks/sidebox_latestreviews.tpl','sidebox_latestreviews.tpl');
if(!($sidebox_latestreviews->is_cached())) {
$results = $db->GetAll("SELECT * FROM ".T_REVIEWS."
INNER JOIN ".T_LISTINGS." ON ".T_LISTINGS.".selector=".T_REVIEWS.".company
WHERE
date_expire > NOW() AND admin_approved=1 AND status='on'
GROUP BY ".T_LISTINGS.".selector
ORDER BY ".T_REVIEWS.".date DESC
LIMIT 8");
if(sizeof($results) > 0) {
foreach($results as $key=>$value) {
if (ifEnabled($results[$key]['membership'], "short_description") AND $value['review'] != "") {
$results[$key]['review'] = limit_words ($value['review'], '50' );
}
$results[$key]['link'] = getListingURL($value['selector'],$value['friendly_url']);
}
}
}
$sidebox_latestreviews->set('reviews',$results);
$sidebox_latestreviews->set('lang',$lang);
//$template_sidebox_latestreviews->set('date_type',$config['date_type']);
$template_sidebox_latestreviews = & new PMDTemplate(PMDROOT .'/template/' . $config['template'] . '/blocks/sidebox.tpl');
$template_sidebox_latestreviews->set('title',$lang['sidebox_latestreviews']);
$template_sidebox_latestreviews->set('content',$sidebox_latestreviews);
$template_sidebox_latestreviews->set('reviews',$sidebox_latestreviews);
This is the html used to display the table:
Code:
<table width="100%" cellpadding="0" cellspacing="0">
<?php foreach($reviews as $value) { ?>
<tr>
<td align="left" valign="top" width="100%">
<span class="text"><a href="<?php echo $value['link']; ?>" ><b><u><?php echo $value['firmname']; ?></b></u></a></span><br />
<span class="text_soft">By <?php echo $value['user']; ?></span>
</td>
</tr>
<tr>
<td align="left" valign="top" width="100%">
<span class="text"><?php echo $value['review']; echo '... <a href="' . $value['link'] . '#' . $value['id'] . '">read more</a></span>';?>
</td>
</tr>
<tr>
<td> </td>
</tr>
<?php } ?>
</table>
Can somebody help? Is there another way that I can limit the length?