How can I SEARCH for topics which have some metadata (Eg. parent.name) that I want to change?

IDEA! You may wish to check out:

  • JQGridPlugin, which gives an editable grid interface to your topics
  • MultiTopicSavePlugin, which doesn't currently have the feature to save parent.name metadata, but does work for formfield values. The author of the plugin would probably welcome a patch, or feature request.
  • Documentation for the /bin/save script, if you want to update parts of topics other than the parent.name metadata

Courtesy of the foswiki-discuss ML:

  1. Collect up a list of pages whose parent is a particular page?
  2. Collect up a list of pages whose parent page is in a particular web (say "Trash")?
  3. Given a list of pages, change the parent of the page to a given page?

We are going to use some techniques that are also used in Tasks.Item10874 which includes an example of a SEARCH that also renders a UI to help with bulk-updating form.name values.

The problem for parent.name is almost exactly the same.

%STARTSECTION{"fixup"}%#FixUp
 %SEARCH{
   "%URLPARAM{"query" default="NOT parent.name" encode="quote"}%"
   type="query"
   header="| *Topic* | *Parent* | *#* |"
   format="| [[$web.$topic]] | '$parent' | \
     <form action='%SCRIPTURL{"save"}%/$web/$topic' method='post'>\
       <input type='hidden' name='redirectto' value='%SCRIPTURL{"view"}%/%BASEWEB%.%BASETOPIC%?section=fix;query=%URLPARAM{"query" default="NOT parent.name"}%;parent=%URLPARAM{"parent" default="%HOMETOPIC%"}%#FixUp'/>\
       <input type='input' name='topicparent' class='foswikiInputField' value='%URLPARAM{"parent" default="%HOMETOPIC%"}%'/>\
       <input type='submit' class='foswikiSubmit' value='Update' display='inline'/>\
     </form> |"
   pager="on"
   pagesize="25"
 }%
%ENDSECTION{"fixup"}%

Here's a UI that allows you to build a query expression and supply a value to set for bulk updating:
%STARTSECTION{"fix"}%<form action="%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%#FixUp" method="GET">
  | Query | <input type="text" name="query" class="foswikiInputField" value="%URLPARAM{"query" default="NOT parent.name"}%"/> |
  | New parent | <input type="text" name="parent" class="foswikiInputField" value="%URLPARAM{"parent" default="%HOMETOPIC%"}%"/> |
  <input type="hidden" name="section" value="fix"/>
  <input type="submit" class='foswikiSubmit' value="Query"/>
</form>
*Results:*
%INCLUDE{"%TOPIC%" section="fixup"}%
%ENDSECTION{"fix"}%

Example queries to try:

   * Search for topics parented to a specific topic:
      * parent.name='WrongParent'
   * Search for topics parented to a topic in Trash web:
      * parent.name~'%TRASHWEB%*'
   * Search for topics with no topic parent, or an empty one:
      * NOT parent.name

Test:

Query
New parent
Results:
Searched: NOT parent.name
Topic Parent #
Support.AttachContentPlugin ''
Support.AttachmentFilterPlugin ''
Support.BasicForm ''
Support.BestPracticeTip14 ''
Support.BioKbPlugin ''
Support.BookmakerPlugin ''
Support.CalDAVPlugin ''
Support.ClamAVScanPlugin ''
Support.CommercialSupport ''
Support.CompareRevisionsAddonPlugin ''
Support.ConsultantBlendedPerspectives ''
Support.ConsultantFosiki ''
Support.CreateInstallGuide ''
Support.DBIStoreContribSchemas ''
Support.DebianPackage ''
Support.DeeplPlugin ''
Support.DelayMacroPlugin ''
Support.DirectedGraphWebMapPlugin ''
Support.DistributedServersPlugin ''
Support.DownloadZipPlugin ''
Support.DuplicateNotificationsFromMailerCon ''
Support.ExpandTopicContentPlugin ''
Support.Extension ''
Support.ExtensionHub ''
Support.ExtensionTemplate ''
Number of topics: 25
Page 1 of 8 Next >

-- PaulHarvey - 08 Jul 2011

Great stuff Paul! Power/admin users will be most grateful.

-- FranzJosefGigler - 08 Jul 2011

Glad you think so! In fact I just used query of TopicClassification='SupplementalDoc' AND parent.name!='SupplementalDoc' to find mis-parented supplemental docs smile

Also fixed a bug where custom query/parent values weren't being carried across redirects.

-- PaulHarvey - 08 Jul 2011

This is very good. Much better than adjusting strikeone etc. IMO, things like this could very well be in the admin tools because there is a good treshold for new admins to make use of this and it's definitely a feature wanted.

-- LarsEik - 08 Jul 2011

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Search
Topic Summary Demonstrate usage of SEARCH on parent.name with a way to more easily bulk-update pages.
Extension
Interested Parties
Related Topics
Topic revision: r5 - 27 Dec 2011, ArthurClemens
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy