strandoo Posted February 24, 2022 Posted February 24, 2022 Hi folks. I've just imported about 200 entries into a site. There's a 'biography' text field that imported into a Body field using the CKEditor. My problem is that when I visit any page with this biography field, the text doesn't look properly formatted (the line-spacing is too tight) because it isn't contained by <p> tags. It looks like the <p> tags are added by CKEditor only when you open/save that page in the Admin editor. I don't want to have to open and save every one of those 200 pages. Does anyone know of a way to do this in the API or something? Cheers!
AndZyk Posted February 24, 2022 Posted February 24, 2022 Hi @strandoo, I think this could work: $biographyPages = $pages->find("biography!="); foreach ($biographyPages as $biographyPage) { $biographyPage->save("biography"); } https://processwire.com/api/ref/page/save/ Regards, Andreas
strandoo Posted March 3, 2022 Author Posted March 3, 2022 @AndZyk Thanks for the response, but this doesn't work. I'm using the Body field, a CKEdit textarea field. When the text was imported, wasn't formatted with <p> tags. Those tags are added (via javascript presumably) when a page of that field type is loaded for the first time in the admin. I think one solution might be to just do a find/replace on that field using the API and add <p> and </p> tags, maybe replacing double line breaks with </p><p> or something. Of course, while working on the site, many of those fields are now properly formatted, so I may make things worse on those pages. I'll have a look at the database content before proceeding.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now