Massive text modify

Hi guys,

I really your need help in order to save lot of time in the future.

I’ve got about 150 pages (is one dynamic page with 50 different pages connected), and, in each page, there are 6 mid-long texts. Those text are stored in a database, at the moment as rich texts.

So now, I’m about to change the graphic of my website, and, consequently, some characteristics of those texts as well (fond size, font, colour, etc).

So how can i modify all the values (font size, font, colour) in a ‘‘massive’’ way?? You can understand that it’ll take too long to do it manually for each text - they would be about 150 pages x 6 texts!

The alternative would be to convert all the rich texts in normal texts, so that I would change only the 6 text in the dynamic page editor. But this method can’t work for me, as those texts need to wrap words several times, and normal texts don’t allow to do it.

To sum up, i’ve found 2 ways, so please tell if one of them is doable:

1- Wrap the lines in a normal text stored and linked in a database.
2- Massively change caracteristics in rich texts.

Thank you in advance for your help!

Andrea

You can try using an afterQuery hook, where you process each item before it is returned to your views, and perhaps write a style parsing function for the text you wish to change per item. pseudo code below might help

//write code in backend/data.js

const modifyTextWithNewStyle = (text)=>`<b>{text}</b>`
export function myCollection_afterQuery(item, context) { 
     item.your_text_field= item.your_text_field && 
     modifyTextWithNewStyle(item.your_text_field);
     return item;
// see below // some changes to the received item return item;
 }