Wruczek / ts-website

A website for your TeamSpeak 3 server
https://ts.wruczek.tech
GNU General Public License v3.0
333 stars 80 forks source link

truncate function and read more in news #220

Closed cataalin closed 6 months ago

cataalin commented 10 months ago

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"],
            ];
        }
Justman100 commented 6 months ago

@Wruczek

Wruczek commented 6 months ago

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