Freemarker Widget Plugin

    Summary

    The Freemarker Widget plugin is intended for use by theme developers. This widget allows you to assign an FTL file from your theme to a widget, allowing you to quickly build templated widgets that are aware of the current user and the container that are placed in.

     

    Supported Versions

    The attached plugin works for Jive 5.0.0.0 to 6.0.1.  Please make sure you download the appropriate jar for the version you are running.

    Screen Shot 2012-04-05 at 9.39.09 PM.png

    Screen Shot 2012-04-05 at 9.44.31 PM.png

     

     

    Setup

    1. Create a new folder in under template/ in your theme called freemarker-widget.
    2. Create a new .ftl file in freemarker-widget.
    3. Configure the widget to use your new .ftl file as the Template.  The folder path and .ftl extension are both optional (i.e. /template/freemarker-widget/test.ftl is the same as just using test)

     

    The following Freemarker variables are available inside the FTL:

    • $templateFile - the path of the current template.
    • $widgetID - a random String that is unique to this widget.  This can be helpful when setting the ID of an object for javascript use.
    • $user - the current user
    • $container - the current container
    • $locale - the current locale

     

    The code example below produced the screenshot at the top of this page:

    <strong>File:</strong> ${templateFile}<br />
    <strong>Widget ID:</strong> ${widgetID}<br />
    <strong>User:</strong> ${user.getName()}<br />
    <strong>Container:</strong> ${container.getName()}<br />
    <strong>Language:</strong> ${locale.getLanguage()}<br />
    
    
    
    
    

     

     

    Gotchas

    • Template must be placed in /template/freemarker-widget of your theme.  Any other paths will be ignored.  This is to prevent users from accidentally using a core FTL that will break the rendering of the page.
    • Regular users can see this widget when editing Social Group and Project widget layouts.  The average user will not know what to do with this widget, but it's important to be aware of this.