[xwiki-users] Link in a Livetable (build with AppWithinMinutes)
Hi, i want to use the AppWithinMinutes-App to build a database of chemicals which we have in our labs. As one column i want to have a link to the wikipedia page of that chemical and i want the link to be displayed and clickable in the table, not only on the page of each entry. To do so i added a Short Text - field for this, but when i add an entry, it's only a link when i type it in the form [[http://de.wikipedia.org/wiki/Zinkfluorid]] and this only on the entry page. In the table it's a trimmed version (for example "org/wiki/Zinkfluorid") and it's no link. But when i type in [[Link>>http://de.wikipedia.org/wiki/Zinkfluorid]] it doesn't work, it's no link anymore and the code is not interpreted. How can i solve this problem? Thanks, zae.
Currently the easiest solution is to use a Large String property type because its content is rendered and so the URL will be transformed in a link. If you want to keep the Short Text property, you can do like this: (1) Edit the application home page in wiki edit mode and make this changes: - 'shortText1': {'type': 'text', 'size': 10, 'filterable': true, 'sortable': true, 'html': false}, + 'shortText1': {'type': 'text', 'size': 10, 'filterable': true, 'sortable': true, 'html': true}, (where 'shortText1' is the ID/name of your property holding the URL) - 'resultPage' : 'AppWithinMinutes.LiveTableGenerator', + 'resultPage' : 'MyCustomLiveTableResults', (2) Create MyCustomLiveTableResults page in the application space with this wiki content: ----------8<---------- {{include document="XWiki.LiveTableResultsMacros" /}} {{velocity}} #if($xcontext.action == 'get' && "$!{request.outputSyntax}" == 'plain') $response.setContentType('application/json') #set($map = {}) #gridresult_buildJSON("$!request.classname" $request.collist.split(',') $map) ## Transform the URL property in a link. #foreach($row in $map.get('rows')) #set($url = $escapetool.xml($row.get('shortText1_value'))) #set($discard = $row.put('shortText1', "<a href=""$url"">$url</a>")) #end #set($json = $jsontool.serialize($map)) ## We have to escape the translation key because it appears as JSON value in the output. #set($escapedEmptyValueTranslationKey = $escapetool.javascript("${request.transprefix}emptyvalue")) $json.replace($escapedEmptyValueTranslationKey, '-') #end {{/velocity}} ---------->8---------- See http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro for more details. Hope this helps, Marius On Thu, Jun 21, 2012 at 3:05 PM, Account <[email protected]> wrote:
Hi, i want to use the AppWithinMinutes-App to build a database of chemicals which we have in our labs. As one column i want to have a link to the wikipedia page of that chemical and i want the link to be displayed and clickable in the table, not only on the page of each entry. To do so i added a Short Text - field for this, but when i add an entry, it's only a link when i type it in the form [[http://de.wikipedia.org/wiki/Zinkfluorid]] and this only on the entry page. In the table it's a trimmed version (for example "org/wiki/Zinkfluorid") and it's no link. But when i type in [[Link>>http://de.wikipedia.org/wiki/Zinkfluorid]] it doesn't work, it's no link anymore and the code is not interpreted. How can i solve this problem? Thanks, zae.
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
Account -
Marius Dumitru Florea