Wruczek/ts-website

truncate function and read more in news

cataalin opened this issue · 2 comments

How could I make long news items that exceed the character limit appear in a read href so that when you click, the missing text appears?, i have several options such as substr from php, with ajax or jquery but I would like it to be in the latte language, integrated into the id of each news item separately since substr takes all the news items together.

        foreach ($data as $row) {
            $newsId = $row["newsid"];

            $newsList[$newsId] = [
                "newsId" => $newsId,
                "title" => $row["title"],
                // There is no separate news pages for now, so we show the entire content as the description
//                "description" => mb_substr($row["content"], 0, 200),
                "description" => $row["content"],
                "added" => $row["added"],
                "edited" => $row["edited"],
//                "link" => "news.php?id=$newsId",
                "external" => false,
                "nombre" => $row["nombre"],
            ];
        }

Would be best to use JavaScript and CSS, hide a portion of the text, then expand it on click.