External Link Choice Provider Plugin

0 vote
Dependency :
compile ":extlinkchoice:0.11"

Documentation Source Issues


Displays external link or internal controller/action as a modalbox popup, Users can choose how they wish for these links to be opened.


grails install-plugin extlinkchoice


Grails plugin which gives your app easy ways of either giving the end user or setting the end user External Link choice to either use Modal to show the link in a popup window, same window, new tab. There is a small menu that can be added to your main.gsp or where required to let user change their choice. The choice is stored in session and so long as further link calls use the same method all links will then open according to set value. There is a little configuration required on your own app and I will provide a sample app as well as this walk through

Please refer to example which has a very basic example.

0.11 moved multi modalbox calls back into one call - modified to include all the goodies from previous version, Controller+Action calls added.
0.10 fix bug from 0.9 working plugin and added extra comments to taglib
0.9 0.8 not resolving hostnames - changed resolv call back to original has a bug 
0.8 converted all fixed values to attributes passed as optional values via taglib
0.7 issues with low resolution and capped content fixed. 
0.6 minor modification to loadmodalbox template - tested and working against standard grails site and kickstart with boostrap
0.5 re-write of most of the plugin.

main.gsp requirements (jquery and if you have no bootstrap enabled extlink:loadbootstrap

<g:javascript library="jquery"/>
<r:layoutResources />

Jquery is called as well as extlink:loadbootstrap, you need to add this to your main.gsp for things to work, if your site is already bootstrapped then no need to do this, you need to call:


rather than


Advanced calls to either loadbootstrap or loadplugincss :


Method 1: Providing link choice

<extlink:userPref update="linkPanel" 
<a href="#" id="linkChooser">Link Choice Chooser</a>
<div id="linkPanel" name="linkPanel" >

Method 2 : Providing link choice:

<extlink:selectPref id='autolinkUpdater' 
noSelection="['null': 'Choose Link Method']" />

Choose either method 1 or 2 not both..

Providing actual link on the page: (2 examples)

choice="${session.linkchoice }" 

<extlink:returnLink link="http://www.example.com" description="example.com" choice="${session.linkchoice }" title="example.com website" />

Internal Links (Controllers/Actions)

description="Tester Controller" 
choice="${session.linkchoice }" 
title="index of Tester Controller" 

The above will produce a link for your controller tester and open index as a link

Resolving External Links resolving hostnames within URL

description="Grails information Site" 
choice="${session.linkchoice }" 

Manually creating your own controller / actions

This may come in handy if you want to pass loads of variables across to your modal box:

<% def g = new org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib() %>
<g:set var="myAttachparams" 
value="[formId:'AttachForm',title:'Attache a file', 
controller: 'mailingListAttachments', 
callPage: 'formAjax' , 
divId: 'mailerAttachments', 
id: 'ATTACH']" />

<% def confirmURL= g.createLink(controller: 'MYController', action: 'MyAction', params:myAttachparams, absolute: 'true' ) %>

<extlink:returnLink link="${confirmURL}" description="My created url" choice="${session.linkchoice}" title="whatever" id="MyModal5" modalLabel="MyModalLabel5" />

Enhanced configuration options for main call to loadboostrap or sitecss explained:

calctype="*" 			[ModalBox: choices : */-+ ]
height="0.6"			[ModalBox: ScreenSize * 0.6 = modalbox height ]
width="0.6"			[ ModalBox: ScreenSize * 0.6 = modalbox width ]
bodyheight="0.4"	[ modal-body: container height default is 0.2 down from actual height ]
bodywidth='98%'		[ modal-body: container width default is 98%]
overflow="hidden"	[ ModalBox: css value for overflow(scrollbars) to display modalbox ]
position="fixed"	[ ModalBox: css value for position to display modalbox ]
top="0"		[ ModalBox: css value for top to display modalbox from ]
margintop='10em'	[ ModalBox: css value for margintop to display modalbox from ]
marginright='auto'	[ ModalBox: css value for marginright to display modalbox from ]
left='auto'			[ ModalBox: css value for left to display modalbox from ]
right='auto'		[ ModalBox: css value for right to display modalbox from ]
iframescrolling='auto' 	[ modal-body: iframe scrolling value ]
iframetransparency='true' [ modal-body: iframe transparency value ]
iframezoom='1'	[ modal-body: iframe zoom  value ]
iframewidth='100%'	[ modal-body: iframe width ]
iframeheight='100%'	[ modal-body: iframe height ] 
iframemargin='0'	[ modal-body: iframe margin ] 
iframepadding='0'	[ modal-body: iframe padding ]

For documentation on how to use this plugin, please visit documentation