From version < 17.1 >
edited by Thomas Mortagne
on 2016/07/22 14:59
To version < 18.1
edited by Ecaterina Moraru (Valica)
on 2017/09/04 13:54
<
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.ThomasMortagne
1 +xwiki:XWiki.evalica
ExtensionCode.ExtensionClass[0]
Description
... ... @@ -1,5 +1,5 @@
1 1  {{info}}
2 -An equivalent feature is available in XWiki Enterprise. See the [[Extension.Tag Application]].
2 +An equivalent feature is available in XWiki. See the [[extensions:Extension.Tag Application]].
3 3  {{/info}}
4 4  
5 5  This snippet will let you rename all the tags with a specific name at once.
... ... @@ -62,4 +62,4 @@
62 62  
63 63  == Result ==
64 64  
65 -{{image reference=RenameTags.png/}}
65 +{{image reference="RenameTags.png"/}}
cogProvides a UI to rename tags from the wiki
Developed by

Bruno Neves

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

An equivalent feature is available in XWiki Enterprise. See the Tag Application.

An equivalent feature is available in XWiki. See the Tag Application.

This snippet will let you rename all the tags with a specific name at once.

Follow these steps:

  • Create a new wiki page
  • Edit it and save it with the present code
  • Insert the name of the tag you want to change
  • Insert the new name
  • Submit

Code

1 Rename Tags

<form name="input" action="$xwiki.getURL("Main.Rename Tags""view")" method="get">
   Tag to replace:
   <input type="text" name="tag1">
   New tag:
   <input type="text" name="tag2">
   <input type="submit" value="Submit">
form>

[All Tags>Main.Tags]

#set ($tagToReplace = "")
#set ($newTag = "")

#if ($request.tag1)
    #set ($tagToReplace = $request.tag1)
#end
#if($request.tag2)
    #set ($newTag = $request.tag2)
#end

#if(($tagToReplace!="")||($newTag!=""))
    #set ($taggedDocs = $xwiki.searchDocuments(", BaseObject obj where doc.fullName=obj.name and obj.className='XWiki.TagClass'"))
   <table>
       <tr>
           <th>Resultsth>
       tr>
       <tr>
           <td>
                #foreach ($taggedDocName in $taggedDocs)
                    #set ($taglist = "")
                    #set ($taggedDoc = $xwiki.getDocument($taggedDocName))
                    #set ($taglist = $taggedDoc.getObject("XWiki.TagClass").get("tags"))
                    #if ($taglist.contains($tagToReplace)) $taggedDoc.getObject("XWiki.TagClass").set("tags", $taglist.replaceAll("(^| +)$tagToReplace( +|$)", "$1$newTag$2"))
                       * [$taggedDoc.fullName] : replacing tag "$tagToReplace" by "$newTag"
                        #set ($discard = $taggedDoc.save())
                    #end
                #end
           td>
       tr>
   table>
#end

Result

RenameTags.png

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Get Connected