Block Insertion

Kris's Avatar


15 Oct, 2010 04:54 PM

Hey everyone. I was wondering if anyone has done something like this.

On our site, we will be using a chunk of XHTML containing the names, addresses, links to maps, etc. for all of our campuses. This information will be in the footer of every page, as well as within the content of multiple pages. What I want to do is place each campus' info in a XHTML block and then reuse that everywhere for easy updates. That's easy enough in the footer because that's in the template. The other places are in random placements within the body copy which is inserted via a WYSIWYG editor in the data definition. I have thought about trying to somehow use a block chooses in the data definition but can't think of a good way then to put that block's XHTML into a place in the body copy.

Any ideas are appreciated!!


  1. 1 Posted by Penny on 22 Oct, 2010 07:39 PM

    Penny's Avatar

    As long as you can get the block content and the page's content into an index block you could so something like the following Velocity format:

    #set( $data = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure") )
    #set( $content = $_SerializerTool.serialize($data.getChild("content"), true) )
    #set( $replacementContent = $_SerializerTool.serialize($data.getChild("replacementContent"), true) )
    $content.replaceAll("replace with contact info", $replacementContent)

    For my example, I just had two WYSIWYGs on a page and searched the one for the phrase "replace with contact info". I then replace that phrase with the content from my other WYSIWYG. You will need to update the XPath to the content regions to where ever they are within your index block. This example will also rely on the user entering the correct phrase where the information is suppose to be pulled in. You can update the replace statement with whatever you decide, bearing in mind that the Velocity Format is actually looking for a regular expression. So if you decide to use special characters, they may need to be escaped.

    I am not completely sure if this is the best way but it was the only way I could come up with.

  2. 2 Posted by Kris on 22 Oct, 2010 09:28 PM

    Kris's Avatar

    Thanks Penny. I will look into trying this. Have a great weekend.

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