求救啊!评论溢出!把中间推到下面去了!评论长就出错了

2016-07-07 16:08 来源:www.chinab4c.com 作者:ecshop专家

求救啊!评论溢出!


2.jpg 1.jpg



代码是

<div class="globalModule" id="brandList">
<h3><div id="list_t_l"><div id="list_t_r"><b>最新评论</b></div></div></h3>
<div id="global_box">
<?php
if(!function_exists("get_comments")){
function get_comments($num)
{
$sql = 'SELECT a.*,b.goods_id,b.goods_thumb,b.goods_name FROM '. $GLOBALS['ecs']->table('comment') .
' AS a,'. $GLOBALS['ecs']->table('goods') .'AS b WHERE a.status = 1 AND a.parent_id = 0 and a.comment_type=0 and a.id_value=b.goods_id '.
' ORDER BY a.add_time DESC';
if ($num > 0)
{
$sql .= ' LIMIT ' . $num;
}
//echo $sql;

$res = $GLOBALS['db']->getAll($sql);
$comments = array();
foreach ($res AS $idx => $row)
{
$comments[$idx]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']);
$comments[$idx]['content'] = $row['content'];
$comments[$idx]['id_value'] = $row['id_value'];
$comments[$idx]['goods_thumb']= get_image_path($row['goods_id'], $row['goods_thumb'], true);
$comments[$idx]['goods_name'] = $row['goods_name'];
}
return $comments;
}
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<!--数据调用-最新评论开始 -->
<?php
$this->assign('my_comments',get_comments(20)); // 数据条数
?>
<!--{foreach from=$my_comments item=comments}-->
<table width="200" border="0" cellspacing="0" cellpadding="0" style=" border-bottom:1px #ccc dashed;">
<tr>
<td width="200" align="left" valign="top">
<div style="height:3px; overflow:hidden;">&nbsp;</div>
<div><a href="goods.php?id={$comments.id_value}" target="_blank"><font style=" color:#FF0000;font-weight:bold;">{$comments.goods_name}</font></a></div>
<div>{$comments.content|truncate:100:""}</div>
<div style="color:#999999;">{$comments.add_time}</div>
</td>
</tr>
</table>
<!--{/foreach}-->
<div style="clear: both;"> </div>
<p class="more">
<a href="message.php"><img alt="" src="../images/bnt_more_1.gif"/> 更多>></a>
</p>
</div>
</div>

回答:
<div>{$comments.content|truncate:100:""}</div>
把上面这句改成:

<div class="word">{$comments.content|truncate:100:""}</div>

不是很懂哦

2楼是告诉你把评论的显示内容缩小控制在100字,这个字数由后面的数字直接控制 你可以根据需要随意改