Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Update TinyMCE Content programmatically

Vote:
 

Hi,

I'm trying to update TinyMCE content(i.e a CSS class) from a set of pages with multiple language versions.

Below are the challenges I'm seeing to access the TinyMCE.

The TinyMCE is located in the below path structure,

Page with multiple page version -> Block -> Block -> Block with TinyMCE.

Since the site has multiple languages the above Blocks and pages are published in different languages, we have to update all those block versions.

As Input, I have a list of page links.

I thought about creating a scheduled job, but it looks time-consuming, So like to create an SQL script if possible. 

Can anyone suggest me a solution?

Thank you,

Hari

#286913
Sep 09, 2022 12:00
Vote:
 

Hi,

Take a look at the table [tblWorkContentProperty]. You'll find TinyMce stores it's markup in the 'LongString' column. You can change it here.

You can work out which content property that value belongs too by plugging fkPropertyDefintionId into [tblPropertyDefinition]

You can also gain further information by querying [tblContentType] and [tblWorkContent] to understand on which page the content property resides.

#287008
Sep 11, 2022 22:03
Vote:
 

Even though I love SQL just as much (probably more?) than the next guy, I think this use case is one of the few where you are better off actually writing an admin tool to do the job.

You'll probably only running this job once, right? A scheduled job will "pollute" your SQL tables tblScheduledItem and tblScheduledItemLog for no good use. Scheduled jobs are for stuff you're scheduling, i.e. running multiple times at a set interval. I guess not everyone will not agree with me on this, and those rows in the database does probably not matter, or you could always delete them later. Anyway, I think it's nice to be aware of them.

If you want to go the SQL route, and only care about published blocks (not old versions or drafts), I don't think you'll need to dig into tblWorkContent. Just run query like this, if the class you are querieing for isn't used elsewhere.

SELECT * FROM tblContent c, tblContentProperty cp
WHERE c.pkId = cp.fkContentID AND LongString LIKE '%class="deprecated"%'

If you do this in code, just do something like this. It shouldn't take long.

  • Get all blocks, or all blocks of the types you care about
  • Loop through all properties (no need to go all strongly typed here)
  • Check if the property is XhtmlStringProperty (and not ContentArea)
  • If the property contains the class, create a writeable clone and update
#287380
Edited, Sep 14, 2022 13:39
Vote:
 

Thank you Surjit and Tomas, Above your input helped me to fetch the Content.

#288112
Sep 26, 2022 10:37
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.