Updating the fixed stylesheet on all HTML text elements

I use a fixed stylesheet to customize the text editor’s wysiwyg. RedDot CMS only offer a possibility on the content class text element. A change on the fixed stylesheet to leads to tons of clicks needed to open all content class folders, content classes and content elements to check all.

This was a perfect motivation to automate this. Please see the complete code first and find below the explanations.

String logonGuid="6E5AC86AEA484CEAA1240C59BDEB7265";
String sessionKey="84818066A2BF4D51A9551BBDE3DF51AF";
String projectGuid="73671509FA5C43ED8FC4171AD0298AD2";

// get fixed text styles
String fixedStyles = IOUtils.toString(new FileInputStream(“d:\\texteditor_styles.txt”));

// open project
CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);

for (TemplateFolder folder : project.getAllTemplateFolders()) {
for (Template template : folder.getTemplates()) {
for (TemplateElement textElem : template.getTextTemplateElements()) {
if (textElem.isHtmlText()) {
System.out.println(folder.getName() +”;”+ template.getName() +”;”+ textElem.getName());

After the usual prologue (replace you login GUIDs!) you see 3 loops finding all content class text elements in all content classes of all folders.

The if checks the found text element to update only the HTML text elements, all ASCII text elements will be unchanged.

The benefit of such a helper is huge. Imagine how many clicks you need to achieve this manually in SmartTree! And, not less important, all text editor behaves definitely in the same way.

In my case I had to ran this code several times until the text editor wysigwyg was perfect.

Now you should be able for similar mass updates on content class elements.  See the javadoc for all set methods on class TemplateElement.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: