Custom Publish Trigger
Hello~!
My team and I just made a custom publish trigger, and we were wondering if we could somehow get the string from the contents of a page object after it has been published. For example, here is a simple code snippet of what we would like to do:
String content = clearWhiteSpace(page.getXHTML());
page.setXHTML(content);
We want to use the clearWhiteSpace method to get rid of extra lines and spaces. Then set the cleaner content to the page again. However, this was returning as null.
Any suggestions?
Thank you!
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 02 Jun, 2015 02:39 PM
Hi,
The
(get|set)XHTML
methods are used for Pages that do not have a Data Definition applied to them (ie only contain a Default WYSIWYG). Let me check with the developers to see if this is possible from a Publish Trigger and I will be in touch as soon as I have additional information.In the meantime, would you be able to elaborate more on the need to remove the extra whitespace? Is this causing issues or something? Also, do you know where is the whitespace coming from, Velocity Formats perhaps?
Please let me know if you have any questions.
Thanks!
2 Posted by jot43536 on 02 Jun, 2015 02:59 PM
Yes, the whitespace is coming from Velocity as far as we know. It isn't causing issues, but whenever we try to download our code to view it or edit it, it has many extra newlines and blank spaces. This program would clean up the code to make it more readable. I have attached an example of the weirdly formatted code that we are returned.
Thanks for the fast reply!
3 Posted by Ryan Griffith on 02 Jun, 2015 03:57 PM
Thank you for the additional information and sample file. It definitely looks like you are dealing with whitespace from Velocity Formats, as you indicated.
Unfortunately, the whitespace coming from Velocity is coming from Velocity itself and not Cascade; however, there are a couple of possible options to help deal with the added whitespace:
If you do want to go the publish trigger route, the only way you could accomplish this would be to read the published file from the Destination server after it was published, strip the whitespace, and write the file back to the server. Our
.docx
publish trigger does something like this where it reads the file from the server, generates a.docx
file, and uploads it to the server.Please let me know if you have any questions.
Thanks!
Tim closed this discussion on 25 Jun, 2015 01:28 PM.