Tags:
create new tag
, view all tags

Pass custom variables when creating a new web

I have the need to automatically set web preferences when creating a new web.

This is the problem; I have a solution below. Let me explain my context.

Context

For an extranet I am creating client webs, one web per client.

The creation of new webs is done by project managers through a web form, that checks the validity of the web name and corrects it if needed. Each web is based on a template web, called _defaultclientweb.

The client name is not necessarily a suitable web name, so I have a variable CLIENTNAME that I can use for page titles. Each client only has access to its own web, the web is restricted to members of the client group. I therefore have the variable CLIENTGROUP, that is also checked by the javascript with the web creation form.

Solution

So my problem was how to insert these variables in the WebPreferences, like WEBBGCOLOR is inserted. My idea is to pass multiple variables as a comma-separated list: "CLIENTNAME=Mercedes,CLIENTGROUP=MercedesGroup,CLIENTLIST=on". These variables are sent as 'customvariables':

<input name="customvariables" type="hidden" value="CLIENTNAME=,CLIENTGROUP=,CLIENTLIST=on" />

I have made some changes to Manage.pm to allow this, see the attached patch.

I have also attached the javascript that does the name error checking and insertion into the field customvariables. This is a version to be inserted in the topic text - there are some <nop>s there that are otherwise not needed.

-- ArthurClemens - 15 Sep 2004

Discussion

I assume you are using some hacked version of ManagingWebs.

  • Yes. -- AC

Couldn't you create TemplateWebs for each client like _THISCLIENT, _THATCLIENT etc and only let them create webs from their own template.

  • I have _defaultclientweb (now mentioned also above). The point is that the preferences in each web should be different, based on the client name. And it should be done automatically. -- AC 15 Sep 2004

-- SamHasler - 15 Sep 2004

How many clients are you talking about? How hard would it be to create a default web for each client?

It's a pity the save script can't be passed a web parameter or you could use direct save with a template to rewrite WebPreferences.

-- SamHasler - 16 Sep 2004

About 100 or so clients. Each year about 10 to 20 clients are added. And the people that are going to operate the TWiki site know nothing about TWiki, or Wikis.

-- ArthurClemens - 16 Sep 2004

I found out its better to use ; as separator than ,. Updated the patch.

-- ArthurClemens - 19 Sep 2004

Perhaps I did not write my thoughts clear enough in the description above. Currently a few variables are passed through the createweb form and set in the new web's WebPreferences: webbgcolor, sitemapwhat, sitemapuseto, nosearchall. I am looking for a way to set other variables, such as a client's name.

As far as I know, this is still not possible with DEVELOP.

Would the patch still be useful to add?

The way I had solved this was to pass a ; separated list of key-value pairs that is plucked apart in the Manage script, for example:

<input name="customvariables" type="hidden" value="CLIENTNAME=Mercedes;CLIENTGROUP=MercedesGroup;CLIENTLIST=on" />

Attaching a new patch (to SVN 4616) (much simpler, thanks to better code base of Manage.pm).

-- ArthurClemens - 12 Jul 2005

why don't you use one hidden input per variable? then you should be able to extend the existing code to allow createweb to set arebitary perferences in WebPreferences? (and you wouldn't have to parse your input for separators at all)

(otherwise - i'm not sure why we limit the variables that can be set from createweb...)

-- SvenDowideit - 13 Jul 2005

That would be better of course. But I am not sure how to do this.

-- ArthurClemens - 13 Jul 2005

I'm assuming from the above that this didn't made it into Dakar so I'm upgrading it to ChangeProposalForm and setting it as ProposedFor EdinburghRelease. If it was in Dakar it needs to have ProposedFor changed to DakarRelease.

-- SamHasler - 29 Apr 2006

Topic attachments
I Attachment History Action Size Date Who Comment
JavaScriptjs customvariables.js r2 r1 manage 3.7 K 2005-07-12 - 23:07 ArthurClemens Javascript example to pass custom variables to new web
Unknown file formatdiff customvariablespatch.diff r1 manage 1.1 K 2005-07-12 - 22:06 ArthurClemens Patch against DEVELOP SVN 4616
Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2006-04-29 - 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.