create new tag
, view all tags

Feature: New user template topic

This started in Support.AddingFormToTWikiUsers.

The format of a new topic is defined by the /twiki/templates/register.tmpl template. This is not consistent with other templates: All templates and skins should be defined in twiki/templates; all template topics (e.g. WebTopicEditTemplate) should be defined as topics in the TWiki web.

The new spec is this:

/twiki/templates/register.tmpl gets replaced by the TWiki.NewUserTemplate topic.

register.tmpl had a %FORMDATA% that got expanded to the content of the registration form, hardcoded as a bullet list. This is now replaced by two %SPLIT% that define the boundaries between form fields. Within the splits, %KEY% and %VALUE% define the form field name and value, respectively. This can be used to generate any format like a table or a bullet list. The TWiki.NewUserTemplate topic generates the same bullet list as before, e.g. it has this split section:

   * %KEY%: %VALUE%%SPLIT%

The code change in the register script is as follows.

    # create user topic if not exist
    if( ! &TWiki::Store::topicExists( $TWiki::mainWebname, $wikiName ) ) {
        my $meta = "";
        my $row = "";
        ( $meta, $text ) = &TWiki::Store::readTemplateTopic( "NewUserTemplate" );
        $text = "%SPLIT%\n\t* %KEY%: %VALUE%%SPLIT%\n" unless $text;
        ( $before, $repeat, $after) = split( /%SPLIT%/, $text );
        for( $x = 0; $x < $formLen; $x++ ) {
            $name = $formDataName[$x];
            $value = $formDataValue[$x];
            $value =~ s/[\n\r]/ /go;
            if( ! (    ( $name eq "Wiki Name" )
                    || ( $name eq "Password" )
                    || ( $name eq "Confirm" ) ) ) {
                $row = $repeat;
                $row =~ s/%KEY%/$name/go;
                $row =~ s/%VALUE%/$value/go;
                $before .= $row;
        $text = "$before$after";
        $meta->put( %_Q__Q_%, ( "name" => $TWiki::wikiUsersTopicname ) );
        &TWiki::Store::saveTopic( $webName, $wikiName, $text, $meta, "", 1 );

Is now in TWikiAlphaRelease.

-- PeterThoeny - 05 May 2002

Stupid User Question ... why are the user preferences visible? Shouldn't these have comment tags around them to make things a bit cleaner? -- EvanLanglois

Another stupid question: why not to put all templates in data/Templates directory, and edit them as standard page, just using browser? This will stimulate immensely skin development. Will also add CVS versioning - so I can undo stupid additions? Let the thousand skins bloom?

-- PeterMasiar - 21 May 2003

I thought the same thing yesterday: templates are just content, content should be held in a configuration web. e.g. one called TWikiTemplates. If someone could code it I would certainly test such a patch! (Too many times I have wiped out a modification I made to a template when installing a new version of a skin; a VC'd version would have allieviated this.)

I'm guessing the how-to is simple for the general case of TWiki-wide templates, principally we are talking about renaming the templates/ directory as data/TWikiTemplates, but there is more complexity at the level of per-web templates. Consider: per-web templates are held as subdirectories of templates.. TWiki is known to not purposefully support subwebs.

For as long as TWiki lacks the much desirable HierarchicallyNestedTwikiWebs I would strongly advocate the use of a web named TWikiSomething rather than just Templates. There is enough pollution of the user's namespace without another addition.

(From a credibility point of view, I think the CoreTeam needs to seriously consider adopting this feature from Sun Microsystem's MegaTWiki: PeterNixon told that Sun rejected TWikiRelease01Feb2003 as it does not offer the HierarchicallyNestedTwikiWebs they require. Such rejection makes the statement of Sun's use of TWiki in TWikiAdvocacy01Feb2003 dubious at best!).

If HierarchicallyNestedTwikiWebs were to be implemented then we could simply use topics named such as TWiki.Templates.Main.TemplatenameTemplate.

-- MartinCleaver - 21 May 2003

Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r8 - 2005-02-15 - SamHasler
  • 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.