Blocks in WYSIWYG

jeberwei's Avatar


12 Jan, 2015 06:56 PM

I am attempting to use a 3rd party form in Cascade without using the embed code.
In doing so, I am thinking of creating a block, that would have a data definition. The user simply inputs the url for the form, i use XSML to create the embed code.

Now, I want to be able to have the use insert this 'block' in the middle of a WSIWYG default region.

Is this possible?
Is there a better method?


  1. 1 Posted by Ryan Griffith on 12 Jan, 2015 08:47 PM

    Ryan Griffith's Avatar


    It sounds like you would want to implement a sort of "short code" (or pseudo tag) where you would have the user enter a predetermined format/pattern and you would have a Format that essentially replaces that content with the desired HTML. For example, they could enter something like:

    {form url=""}

    In this case, I would recommend using Velocity because it would give you much more flexibility.

    I believe our Services team may have helped a client with something similar. Let me loop them into this discussion to see if they may be able to provide you with some sample code.

    Please let me know if you have any questions.


  2. 2 Posted by Ryan Griffith on 19 Jan, 2015 02:59 PM

    Ryan Griffith's Avatar


    I wanted to follow up with an example for my previous suggestion on using a sort of shortcode syntax and replacing the content using a Format.

    Let's assume you use the following syntax and simply need to reference a URL to your external form:


    Using Velocity, we can create a macro that uses a regular expression to match the shortcode and replace it with an <iframe> tag:

    #macro (expandFormShortcode $str)
        $str.replaceAll("\{form\}(.*)\{/form\}", "<iframe src='$1'/>")

    You would then call the macro and pass in your WYSIWYG string, or any other string that contains the shortcode:

    #set ($content = $_SerializerTool.serialize($wysiwygField,true)) 

    Please let me know if you have any questions.


  3. Ryan Griffith closed this discussion on 16 Feb, 2015 08:51 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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