2
I need to limit characters in a text, and should keep (...). The title is sticking out of the layout.
if($related){
echo '
<div class="row">
<div class="medium-12 columns">
<div class="ap-ads-related">
<h2>Anúncios Relacionados</h2>
<div class="row">
';
foreach ($related as $key => $rel) {
$related_images = $this->ads_model->images($rel->ad_id);
$related_image = thumbnail(@$related_images[0]->ads_img_file, "ads", 260, 180, 2);
echo '
<div class="small-6 medium-3 end columns">
<a href="'.base_url('anuncio/'.$rel->ad_slug).'" title="'.$rel->ad_name.'" class="item">
<div class="image"><img alt="'.$rel->ad_name.'" src="'.$related_image.'"></div>
<h4>'.$rel->ad_name.'</h4>
<div class="price">'.(($rel->ad_service) ? 'Serviço' : string_money($rel->ad_price)).'</div>
</a>
</div>
';
}
echo '
</div>
</div>
</div>
</div>
';
}
?>
@Willian I did not research a solution with Codeigniter, my fault, I made a manual solution using a helper, but the solution here of the partner does not reinvent the wheel. (+1) Which doesn’t mean mine isn’t useful, but this one was actually better
– user26552
I’m kind of a layman in codeigneiter, could you pass the complete code correctly? I wanted to see if it works
– user54225
Just insert in place of $rel->ad_name this: print character_limiter($rel->ad_name, 25), do the test.
– Maurício Krüger