ArchivePage 2 of 24

Autocomplete parent topic in NatEdit

What I really miss in Foswiki 1.0.4 with NatSkin was the ability to view all the existing topics within the web and choose which topic is my parent topic. Currently, NatEdit wants you to know the exact name of the parent topic – not quite interesting.

So, I’ve made a simple tweak that allows me to search all the existing topics in the web as I type. Result? I’m able to search for a parent topic by its name. Not exactly perfect, but it fits well so far.

There are 3 parts to achieve this.

1. Create SEARCH term to list all the topics in the web

%SEARCH{ ".*" type="regex" web="%WEB%" scope="topic" nonoise="on" nototal="on" multiple="off" separator=", " format="'$topic'" }%

2. Integrate the above with JQueryPlugin
We’ll be using jquery.autocomplete for the completion of the input field.

<script>
  $(function(){
    $("#topicparent").autocomplete(
      [ %SEARCH{ ".*" type="regex" web="%WEB%" scope="topic" nonoise="on" nototal="on" multiple="off" separator=", " format="'$topic'" }% ]
    );
  });
</script>

3. Modify edit.natedit.tmpl
We need to modify /<path_to_foswiki>/templates/edit.natedit.tmpl to include all the above. So it should look like this…

  <div class="twikiFormStep foswikiFormStep twikiFormLast">
    <h3>%MAKETEXT{"Parent topic"}%:</h3>
%JQSCRIPT{"jquery.autocomplete"}%
%JQSTYLE{"jquery.autocomplete"}%
<script>
    $(function(){
        $("#topicparent").autocomplete(
            [ %SEARCH{ ".*" type="regex" web="%WEB%" scope="topic" nonoise="on" nototal="on" multiple="off" separator=", " format="'$topic'" }% ]
        );
    });
</script>
    <input class="twikiInputField" id="topicparent" type="text" name="topicparent" size="40" value="%TOPICPARENT%" />
  </div>

Looking for an internship?

Look no further!

View this document for more information!

Foswiki 1.0.4 released!

Foswiki was forked from TWiki a couple of months ago, and just yesterday/today, they have their second release 1.0.4!

Congrats to the release manager, developers, testers and translators in making this a success! It’s definitely going in a better direction that TWiki, IMHO. Quite a significant amount of the core is refactored, new features are added (especially a more stable TinyMCE), and overall a thriving community that looks at users rather than its commercial implications are just some advantages that Foswiki have been working on.

Now I just need to find time to complete the migration from TWiki to Foswiki by following this guide. :)