Inline Tag Edition
Last modified by Thomas Mortagne on 2021/03/18 11:28
Edit tags directly while viewing the wiki page |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
This snippet will let you edit tags directly while viewing the wiki page you want to tag via a basic text input field.
Follow these steps:
- Create a new wiki page
- Edit it and save it with the following text: #includeForm("Panels.PanelSheet")
- Add a "Panels.PanelClass" instance to the page
- Put the code below in the content field of the panel
Code
#if ($context.action == "view")
#panelheader("Tags")
#set ($tags = $doc.tags.split("[|]"))
#set($existingTags = $xwiki.arrayList)
#foreach($tag in $!tdoc.tags.split("[|]"))
#set($discard = $existingTags.add($tag))
#end
#if ($existingTags.size()>0 && $existingTags.get(0).length()>0)
#foreach ($tag in $existingTags)
* <a href='$xwiki.getURL("Main.Tags")?tag=$tag'>$tag</a>
#end
#end
<form action="$xwiki.getURL($doc.fullName,"save")" method="get">
<center>
<input name="tags" value="$!doc.tags" type="text"/>
<input type="submit" value="Update tags"/>
</center>
</form>
#panelfooter()
#end
#panelheader("Tags")
#set ($tags = $doc.tags.split("[|]"))
#set($existingTags = $xwiki.arrayList)
#foreach($tag in $!tdoc.tags.split("[|]"))
#set($discard = $existingTags.add($tag))
#end
#if ($existingTags.size()>0 && $existingTags.get(0).length()>0)
#foreach ($tag in $existingTags)
* <a href='$xwiki.getURL("Main.Tags")?tag=$tag'>$tag</a>
#end
#end
<form action="$xwiki.getURL($doc.fullName,"save")" method="get">
<center>
<input name="tags" value="$!doc.tags" type="text"/>
<input type="submit" value="Update tags"/>
</center>
</form>
#panelfooter()
#end
Result
See also a live example.