Question
I am struggling to understand how to create a template in twiki. Essentially what I want is a form with field that specifies the name of topic to create and button to submit the form. Once the user submits the form an edit page will come up with prefilled headings. Thats pretty much it.
The topic would be something like currentweb.topic.user-supplied topic. This template can't be the default template for the currentweb. It should only be used through the form. Basically it should work like this page is working. When I clicked on create to post this question, it supplied the Environment, Question headings, etc.
Can someone give me the step-by-step. I have read the documentation and understand it, but I can't seem to implement this correctly.
Any help would be appreciated.
Environment
| TWiki version: |
|
| TWiki plugins: |
|
| Server OS: |
|
| Web server: |
|
| Perl version: |
|
| Client OS: |
|
| Web Browser: |
|
--
JeremyWeber - 13 Jan 2004
Answer
This won't be a complete step-by-step, but I will give you a few pointers to get started. The two pieces that you need to accomplish what you describe above is:
- An HTML form for the user to enter the information that will go into the new topic, and
- A template topic that contains the default content/structure for the new topic.
The magic of how the information the user enters into the form gets placed within the template happens with the URLPARAM variable (which is explained in the link above).
The way I learned how this actually works (as someone with virtually no prior HTML experience) is by examining (and frankly copying) the sample
TWikiApplication on this site. There is, of course, this one for entering new support questions and there are
several others examples in the
Sandbox web. What I do is:
- Look at the page with the HTML form in "raw" form. This allows you to see the formatting without actually editing the topic. To do this, simply add "?raw=on" to the url. Examining the HTML form will show you how the URL parameters are defined and how the template topic is invoked. Don't be intimidated if the actual structure of the HTML form appears very confusing at first. Like I said, when I got started, I literally copied examples from this site and then modified them to meet my needs. Pretty quickly, they will start to make sense.
- Look at the tempate topic in edit or raw view to see how the URLPARAM variable (and other variables) are used to "fill in" data.
- Finally, try filling in a form (such as the "Ask a question" form in this web) and click on the submit bottom (or in this example, "Create Question Page") and then look at the URL created (in your address bar). (You can then hit cancel or "back" if you don't want to actually save the new topic.) This will show you what URL parameters are passed to the template topic.
That's about it. I would recommend starting out by studying the support question application or the
ItemToDo application because they are pretty straight forward and also make good use of
TWikiForms. Sample applications like
DiscussionForum are significantly more complex but are worth studying later as they contain some valuable "tricks".
Feel free to also check out this
topic classification application
I created on my own site to create new "sets" of topics, each with their own topic template.
Hope this helps!
--
LynnwoodBrown - 13 Jan 2004