function smarty_modifier_truncate($string, $length = 80, $etc = '...',
$break_words = false, $middle = false)
{
if ($length == 0)
return '';
if (strlen($string) > $length) {
$length -= min($length, strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
}
if(!$middle) {
return substr($string, 0, $length) . $etc;
} else {
return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
}
} else {
return $string;
}
}
// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;
echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td valign="top" class="forum">
<a href="', $post['href'], '" target="_blank">', $post['subject'], '</a>
</tr>';
echo '
</table>';
}
<?php
function short_name($str, $limit)
{
return strlen($str) > $limit ? substr($str, 0, $limit - 3) . '...' : $str;
}
?>
Merci comemeFloBaoti a dit:Si tu ne sais pas comment utiliser une fonction en PHP, on ne peux pas faire grand chose pour toi...
Tu calles la fonction dans tes fichiers, et tu l'utilises où tu veux...
➡️ Offre MyRankingMetrics ⬅️
pré-audit SEO gratuit avec RM Tech (+ avis d'expert)
coaching offert aux clients (avec Olivier Duffez ou Fabien Faceries)
Voir les détails ici