WebCreateNewTopicComponents

This topic is meant for developers. It contains INCLUDE sections to build a "create new topic" form.

Usage

Including the form (simple)

Create a form with an empty name field:
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="newtopic"
    newtopic=""
}%

Create a form with an "auto increment" name, and with customised INCLUDE sections in topics listed in override param:
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="newtopic"
    newtopic="TestTopicAUTOINC0"
    override="%USERSWEB%.TopicFields,%BASEWEB%.TopicFieldsForWeb"
}%

Customizing the order and layout

See the component table below what parts you can use to construct a form.

This is the code used in the Sandbox.Web Home form:
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="js"
}%
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="formstart"
}%
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="topicname"
    newtopic=""
}%
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="topicnamefeedback"
}%
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="wikiword"
}%
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="errorfeedback"
}%
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="submit"
}%
</div>
</div>
%INCLUDE{
    "%SYSTEMWEB%.WebCreateNewTopicComponents"
    section="formend"
}%

List of components

Component Description
js Includes necessary Javascript files
formstart Opens the form
topicname Topic name field
wikiword Javascript to automatically construct topicname text to Wiki Word and tickbox to allow non-WikiWords
topicnamefeedback Provides feedback on the automatically constructed topic name
topicparent Input field with toggle to select list of topics in the current web to select as topic parent
templatetopic Select list of template topics
errorfeedback Provides feedback on why the submit button is disabled
submit The submit button
formend Closes the form


%STARTSECTION{"newtopic" override="" sectionlist="js, formstart, topicname, submit, topicnamefeedback, errorfeedback, formend"}%%FORMAT{
    "%sectionlist%"
    type="string"
    format="$percntINCLUDE{
    $quot%override%,%TOPIC%$quot
    section=$quot$item$quot
}$percnt"
}%%ENDSECTION{"newtopic"}%

%STARTSECTION{"js"}%%TMPL:P{"JavascriptFiles/foswikiString"}%%TMPL:P{
   "LIBJS"
   id="JavascriptFiles/foswikiStringUnicodeChars"
   requires="JavascriptFiles/foswikiString"
}%%TMPL:P{
   "LIBJS"
   id="JavascriptFiles/foswikiWebTopicCreator"
   requires="JavascriptFiles/foswikiStringUnicodeChars"
}%%ADDTOZONE{"head" 
   tag="WebCreateNewTopicTemplate:META" 
   text="<noautolink><literal><meta name='foswiki.webTopicCreator.nameFeedback' content='%MAKETEXT{"Topic will be named: "}%' />
<meta name='foswiki.webTopicCreator.errorFeedbackNoWikiName' content='<p class=\"foswikiGrayText\">%ENCODE{"%MAKETEXT{"Enter the topic name as WikiWord or check the allow non-Wiki Word box."}%" type="entity"}%</p>' /></literal></noautolink>"
   requires=""
}%%ENDSECTION{"js"}%

%STARTSECTION{"formstart" defaultweb="%INCLUDINGWEB%"}%<form name="newtopicform" action="%SCRIPTURLPATH{edit}%/%defaultweb%/">
<input type="hidden" name="t" value="%GMTIME{"$epoch"}%" />
<input type="hidden" name="onlynewtopic" value="on" />%ENDSECTION{"formstart"}%

%STARTSECTION{"webname"}%    <select name="defaultweb" class="foswikiSelect"> 
     <option>%SANDBOXWEB%</option>
    %SEARCH{
        type="query"
        web="all,-%SANDBOXWEB%"
        topic="%WEBPREFSTOPIC%"
        "1"
        format="<option>$web</option>"
        nonoise="on"
    }% </select>%ENDSECTION{"webname"}%

%STARTSECTION{"topicname"}%<input type="text" class="foswikiInputField" name="topic" size="40" placeholder="%IF{
    "defined placeholder"
    then="%URLPARAM{"placeholder" default="%placeholder%"}%"
}%" value="%IF{
    "defined newtopic"
    then="%URLPARAM{"newtopic" default="%newtopic%"}%"
    else="%IF{"$BASETOPIC='WebCreateNewTopic'" then="" else="%BASETOPIC%"}%"
}%" />%ENDSECTION{"topicname"}%

%STARTSECTION{"wikiword"}%%TMPL:P{"onlywikiname"}%%ENDSECTION{"wikiword"}%

%STARTSECTION{"topicnamefeedback"}%<span class="webTopicCreatorFeedback foswikiGrayText"><!--generated name will be put here--></span>%ENDSECTION{"topicnamefeedback"}%

%STARTSECTION{"topicparent"}%
%JQREQUIRE{"ui::autocomplete"}%
%INCLUDE{"%SYSTEMWEB%.JQueryAjaxHelper" section="topicselector" INPUT_VALUE="%URLPARAM{"topicparent" default=""}%" INPUT_NAME="topicparent" EXCLUDE="%TOPIC%" PLACEHOLDER="%MAKETEXT{"Enter parent name"}%" }%
%ENDSECTION{"topicparent"}%

%STARTSECTION{"templatetopic"}%<select name="templatetopic" class="foswikiSelect">%IF{"'%URLPARAM{"templatetopic"}%'" then='<option selected="selected">%URLPARAM{"templatetopic"}%</option>'}%<option value="">%MAKETEXT{"Default template"}%</option>%SEARCH{"name~'*Template'" scope="topic" topic="*Template" web="%BASEWEB%" excludetopic="*EditTemplate,*WebCreateNewTopicTemplate,*ViewTemplate" type="query" nonoise="on" format="<option value=\"$web.$topic\">$topic</option>"}%</select>%SEARCH{"name~'*Template'" scope="topic" topic="*Template" web="%BASEWEB%" limit="1" excludetopic="WebTopicEditTemplate,*WebCreateNewTopicTemplate,*ViewTemplate" type="query" nonoise="on" format=" <span class='foswikiUnvisited'>%POPUPWINDOW{
url="%SCRIPTURL{view}%/%SYSTEMWEB%/WebTemplateTopics?web=%BASEWEB%;template=viewplain"
template="viewplain"
toolbar="1"
label="%MAKETEXT{"View templates"}%"
}%</span>"}%%JQREQUIRE{"popupwindow"}%%ENDSECTION{"templatetopic"}%

%STARTSECTION{"errorfeedback"}%<div class='webTopicCreatorError'><!--generated name will be put here--></div>%ENDSECTION{"errorfeedback"}%<

%STARTSECTION{"submit"}%<input type="submit" class="foswikiSubmit" value='%MAKETEXT{"Create this topic"}%' />%ENDSECTION{"submit"}%

%STARTSECTION{"formend"}%</form>%ENDSECTION{"formend"}%

Topic revision: r1 - 15 Jul 2017, ProjectContributor
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback