Using Jive Managed Snippets Plugin

Managed Snippets Plugin for Jive is awesome. It allows administrators to define sort of “macros” that can be reused on a Jive portal. The best part is that it allows to workaround the regular limitation for using javascript and HTML tags. Yes, that’s right, you can use Javascript, IFRAMEs and all HTML tags in the managed snippets. This is a very elegant way to allow users use limited and well-managed Javascript without exposing site to XSS attacks.

Originally this plugin was only available for place types only. For instance you can insert it via Customize->Other->Managed Snippets menu into a group overview and include a google map for instance. However as of 1.0.3.0 you can also use it in user posts, documents, virtually any objects. Here is how you can do it and a few caveats:


First you need to define the managed snippet, give it a name and a content: Admin Console->System->Settings->Manage Snippets.

After the snippet is defined you can immediately start using it as a widget. If you want to insert it into a post/object you can use this syntax:

snippet://<snippet_name>?key1=val1&key2=val2...

The entire “?key1=val1&key2=val2” part can be omitted if you do not use parameters in the managed snippet. The way you introduce parameters in the managed snippet is “::key1::”. For instance

<img src="http://::key1::/::key2::"/>

will render as

<img src="http://val1/val2"/>

if you embed it as “snippet://?key1=val1&key2=val2″

Unfortunately if you will try using snippet with a more complex definition it will not work in a user object even though it might work as a widget perfectly fine. Only snippets that can be validated as XML will work in user objects. You can use this online tool to validate your snippet code: http://www.xmlvalidation.com/. Here is another, less friendly but more official alternative: http://www.w3schools.com/xml/xml_validator.asp.

Another catch is that you should not use the snippet editing textarea in most cases. For instance if your snippet code contains “&” you will need to convert it into “&amp;” (this is a very common character in URLs for instance). After you save this code as a snippet the editor in Jive will render those “&amp;” as “&” even though the actual code is stored correctly. I’d recommend editing your snippet code in external editor, then copypasting the code into Jive and saving it. Do not try to edit in Jive editor.

I also experienced some difficulties trying to embed more than one managed snippet as a widget. If you tried to do that and cannot edit any of those widgets anymore you can reset the customizations to default and start over.

Also the snippets seem to be not rendering in the previews like “Recent Activity”. This actually could be a right thing to do, though.


You can read more about managed snippets plugin here: https://community.jivesoftware.com/docs/DOC-63200

Huge thanks to the plugin author Ryan Rutan for helping with figuring our all this.

Also many thanks to Ben Taub for his help in testing this feature.

Leave a Reply