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>