Hello everybody,
I have some collections to display sport athletics chronicles, the field for the chronique is an RICH HTML type.
If I show the field content when the text field is connected to the collection the HTML is shown correct. But in a page, I want to show only the first words of the chronicle with “…continue reading”, so I use this code:
let fullText;
let shortText;
$w.onReady( function () {
$w(“#repeater1”).onItemReady( ($w, itemData, index) => {
const shortTextLength = 200;
const monthNames = [“Gener”, “Febrer”, “Març”, “Abril”, “Maig”, “Juny”, “Juliol”, “Augost”, “Setembre”, “Octubre”, “Novembre”, “Desembre”];
const strDate = itemData.data.getDate().toString();
const strMonth = monthNames[itemData.data.getMonth()];
const strYear = itemData.data.getFullYear().toString();
$w("#text20").text = strDate + " de " + strMonth + " de " + strYear;
fullText = itemData.cronica;
shortText = fullText.substr(0, shortTextLength) + " (continuar llegint...).";
$w("#text22").text = shortText;
});
});
Here I convert the DATE & TIME format into my language avoiding to show the hour and i works.
But when I want to show the first 200 chars of the field Data.cronica, the variable shortText gets the HTML format and it don’t show the text. Take a look:
https://www.atletismecanyelles.com/prova
Under Tipus: 5 km you can see the text with all the HTML tags.
How could I convert the rich HTML into plain text without the tags?
And another question. I’d like that the text “…continue reading” would be a link to the full chronicle. How could do it?
Thanks a lot,
Francesc Gallardo