SID-02382: Set TOPICTITLE on topic creation
| Status: |
Answered |
TWiki version: |
6.0.2 |
Perl version: |
|
| Category: |
CategoryTemplates |
Server OS: |
|
Last update: |
2 years ago |
How can I set the TOPICTITLE to the value of an input field when creating a new topic with te SAVE script?
My goal is to add the TOPICTITLE to the Metadata of the topic.
I guess I have to save the META:FIELD "Title", but have no idea how to do this.
--
Emiel Van Riel - 2018-12-03
Discussion and Answer
See
TWikiReleaseNotes06x00, section "New TOPICTITLE Feature". The
%TOPICTITLE% is the variable you use, not set. The variable is either defined by a form field named Title, or by a preferences setting named TITLE.
If you use a form on new topics, add a
Title key with value
"My nice title" to the post data, typically via input field.
If you don't use a form on new topics you can set the TITLE preferences setting by adding a
metapreferences key with value
" * Set TITLE = My nice title" to the post data. If you use an input field you'd need to use some
JavaScript to prefix the
" * Set TITLE = " to user input on form submit.
--
Peter Thoeny - 2018-12-06
Clear. Thanks.
--
Emiel Van Riel - 2018-12-06
Now I am trying to set the TOPIC TITLE on topic creation by setting the
metapreference with post data from an input field. I tried:
<input type='hidden' name='META:PREFERENCE' value=' * Set TITLE = Some nice name' />
and
<input type='hidden' name='META:PREFERENCE' value='{"name":"TITLE", "title":"TITLE", "type":"Set", "value":"Some nice name"}' />
with no result.How to make this work?
--
Emiel Van Riel - 2023-10-09
This is not directly supported, but you can do it in a hacky way: Add a hidden input field named
text with value
%META:PREFERENCE{name="TITLE" title="TITLE" type="Set" value="My custom topic title"}%
See example with visible textarea named
topic at
Sandbox.CreateNewTopic
Alternatively, here is a cleaner way: Create a template topic that has a form with a field called
Title. In the create new topic form add a hidden field named
templatetopic where the value has the name of the template topic. Add another hidden field named
Title where the value has the custom topic title. See details at
TWikiScripts
--
Peter Thoeny - 2023-10-11
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.