Topic: Custom Page truncation
I managed to truncate the characters of the custom page to (25) to be displayed on the front page of the portal. How can I make it so that it displays '...' if there is more text on the subject line? So if for example it says:
text to be read - <- end text
this is the text I want you to read whe...
Hope you follow what I am trying to say. Here is the code below if someone can assist me.
<?php
//get all pages info from the DB
$result = $db->query('SELECT id, title FROM '.$db->prefix.'pages') or error('Unable to select pages from database', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
$trunc_len = 20; // Set amount of text to be displayed in subject.
?>
<div class="block">
<h2 class="block2"><span>Custom Page Links</span></h2>
<div class="box">
<div class="inbox">
<ul>
<?php
while($page_data = $db->fetch_assoc($result))
echo "\t\t\t\t\t\t\t".'<li>'."\n\t\t\t\t\t\t\t\t".'<a href="page.php?id='.$page_data['id'].'">'.substr($page_data['title'], 0, $trunc_len).'</a></li>'."\n\t\t\t\t\t\t\t"."\n";
?>
</ul>
</div>
</div>
</div>
<?php
}
?>