Inline Tag Edition

Last modified by Thomas Mortagne on 2021/03/18 11:28

cogEdit tags directly while viewing the wiki page
TypeSnippet
Category
Developed by

slauriere

Rating
0 Votes
LicenseGNU 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:

  1. Create a new wiki page
  2. Edit it and save it with the following text: #includeForm("Panels.PanelSheet")
  3. Add a "Panels.PanelClass" instance to the page
  4. 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

Result

tag_panel.png

See also a live example.

Tags: tag
     

Get Connected