Truncate Client Name on client side nav

This commit is contained in:
johnnyq 2023-09-08 01:51:29 -04:00
parent 21a60c0619
commit 6cb3d8f9d0
2 changed files with 5 additions and 2 deletions

View File

@ -2,7 +2,7 @@
<aside class="main-sidebar sidebar-dark-<?php echo nullable_htmlentities($config_theme); ?> d-print-none">
<a class="brand-link pb-1 mt-1" href="clients.php">
<p class="h5"><i class="nav-icon fas fa-arrow-left ml-3 mr-2"></i> Back | <strong><?php echo initials($client_name); ?></strong></p>
<p class="h5"><i class="nav-icon fas fa-arrow-left ml-3 mr-2"></i> Back | <strong><?php echo truncate($client_name,11); ?></strong></p>
</a>
<!-- Sidebar -->

View File

@ -192,7 +192,10 @@ function truncate($text, $chars) {
}
$text = $text." ";
$text = substr($text, 0, $chars);
$text = substr($text, 0, strrpos($text, ' '));
$lastSpacePos = strrpos($text, ' ');
if ($lastSpacePos !== false) {
$text = substr($text, 0, $lastSpacePos);
}
return $text."...";
}