Tags:
create new tag
view all tags

Question

When creating a topic body you are allowed to define a link to an other topic in the way

[[New Topic Name]]

which is automatically converted into a valid Wiki name when viewed.

But how to do this when creating a new topic using a html form:

<form name="new" action="/cgi-bin/edit/Support/">
   * New topic: 
     <input type="text" name="topic" value="" size="23" />
     <input type="hidden" name="templatetopic" value="MyTemplate" />
     <input type="submit" value="Create" />
</form>

Actually, when i enter a non Wiki name in the form i am informed that i tried to create a topic whose name is not a WikiName.

What i want is that the user don't have to enter a Wikiname - instead the topic name entered into the form is automatically converted into one.

Is this possible ? How it have to be done ?

  • TWiki version:1 Dec. 2001
  • Web server: Apache
  • Server OS: SunOS
  • Web browser: Netscape 4.7
  • Client OS: Win NT

-- PetricFrank - 10 Jan 2002

Answer

On my TWiki site I've been working on a system to do something similar. I let people enter Bible verses with a pulldown for the book, then entry fields for the chapter and verse. Then JavaScript assembles the formfields and sends you to the created page. Kind of a pain but was fun. You have to play some tricks to get javascript to work in some cases as you fight the TWiki processing ( see NoTwikiWordsBetweenScriptTags ) Hope looking at my script helps you out.

http://www.mattwalsh.com/twiki/bin/view/Test/VersePrototype

Reply

Your workaround is good, but why the creation of the topic does not work ?

Even if i add

<input type="hidden" name="onlywikiname" value="off" />

to the form, it complains about topic to create not having a wiki name.

Using the option above i expect the edit script creates a wiki name from the name given.

Am i wrong ?

Update

I've changed bin/edit at line 72 from

    # prevent non-Wiki names?                                                              
    if( ( $onlyWikiName ) && ( ! &TWiki::isWikiName( $topic ) ) &&                         
        ( ! &TWiki::Store::topicExists( $webName, $topic ) ) ) {                           
        # do not allow non-wikinames, redirect to view topic                               
        TWiki::redirect( $query, &TWiki::getViewUrl( $webName, $topic ) );                 
        return;                                                                            
    }                                                                                      

to

    # prevent non-Wiki names?                                                              
    if( ( $onlyWikiName ) && ( ! &TWiki::isWikiName( $topic ) ) &&                         
        ( ! &TWiki::Store::topicExists( $webName, $topic ) ) ) {                           
        # do not allow non-wikinames, redirect to view topic                               
        TWiki::redirect( $query, &TWiki::getViewUrl( $webName, $topic ) );                 
        return;                                                                            
    } else {                                                                               
        $topic =~ s/^\s*//;                                                                
        $topic =~ s/\s*$//;                                                                
        $topic =~ s/^(.)/\U$1/;                                                            
        $topic =~ s/\s([a-zA-Z0-9])/\U$1/g;                                                
                                                                                           
        if( ( ! &TWiki::isWikiName( $topic ) ) &&                                          
            ( ! &TWiki::Store::topicExists( $webName, $topic ) ) ) {                       
            # do not allow non-wikinames, redirect to view topic                           
            TWiki::redirect( $query, &TWiki::getViewUrl( $webName, $topic ) );             
            return;                                                                        
        }                                                                                  
    }                                                                                      

This does it for me. Any problems with that ?

Probably somebody integrates this to official wiki.

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2002-05-21 - TWikiAdmin
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.