¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.
JScms_cut_content
The JScms_cut_content
function truncates text to a specified limit while ensuring no broken words or partial sentences.
It optionally preserves full sentences if punctuation exists within a reasonable range of the limit.
JScms_cut_content($text, $limit = 200)
$text
: (string) The input text to truncate.$limit
: (int) Optional. The maximum number of characters. Default is 200
.(string) The truncated text with ellipsis if it exceeds the limit.
<?php
$text = "This is a long text. It needs truncating to a reasonable length.";
$shortText = JScms_cut_content($text, 50);
echo $shortText; // Outputs: "This is a long text."
?>
$limit
parameter is appropriate for the context to avoid cutting too much content.