SID-01112: Defining User Variables in One Topic
| Status: |
Answered |
TWiki version: |
5.0.1 |
Perl version: |
5.8 |
| Category: |
CategoryAutomation |
Server OS: |
RedHat Linux 7.4, kernel 2.4.21 |
Last update: |
14 years ago |
How can I construct a topic that sets user variables for a list of users that would, in plain language, say: "Set LOCALID for BrentEaton to VcTemple."
I am setting up a demonstration project in which users will have a "home page" that is focused on their clinical discipline, not their location:
- BrentEaton is a chaplain in Temple. His LOCALID = VcTemple
- JohnDoe is a chaplain in Austin. His LOCALID = VcAustin
- JohnSmith is a chaplain in Dallas. His LOCALID = VcDallas
They all start on the same home page
I want their local directors to be able to show headlines for local topics on the discipline's home page. For instance, the Dallas chaplain would have a generic chaplain home page, but Temple site news would be visible to that chaplain. I would have an
INCLUDE on the home page that called the variable to match part of the name of the topic containing the local headline, like this:
%INCLUDE{SomeWeb.Subweb.%LOCALID%sitenews}%
I can make this work easily if I write
* Set LOCALID = VcTemple on the Temple chaplain's user page, but that is tedious when dealing with a large group of users in many locations.
If implemented, I will probably get a spreadsheet of usernames/passwords with disciplines, locations and other attirbutes and would need to construct formulas to transform the cell contents in to variable statements. I just don't know if I can "set" these user variables in another topic.
Any suggestions?
--
BrentEaton - 2011-02-18
Discussion and Answer
Personally I would delegate the selection of the LOCALID to the users. You could define a new form field called LOCALID in the Main.UserForm with as selector for the local ID. Send an e-mail to your users asking to edit their profile page and select the LOCALID in the form. With this setup, write the following in the TWiki homepage:
%INCLUDE{
"SomeWeb.Subweb.%FORMFIELD{ "LOCALID" topic="%WIKIUSERNAME%" }%SiteNews"
warn="Please edit your homepage at %WIKIUSERNAME% and select the LOCALID in the form to see site news relevant to your location."
}%
An alternative is to define the user to LOCALID relationship in a TWiki table and use a
FormattedSearch to query the right LOCALID. Here are some hints:
* LOCALID of BrentEaton: VcTemple
* LOCALID of JohnDoe: VcAustin
* LOCALID of JohnSmith: VcDallas
Do a multiple="on" SEARCH that identifies just the bullet of the logged in user, and apply a pattern to pull the ID. Untested:
%SEARCH{
"\* LOCALID of"
type="regex"
topic="UserToLOCALID"
multiple="on"
format="$pattern(.* LOCALID of %WIKIUSERNAME%:[^A-Z]*([A-Z-a-z]*).*)"
nonoise="on"
limit="1"
}%
If the search is done as intended it will return=VcDallas= for JohnSmith. Details in
VarSEARCH and
FormattedSearch.
Now you can embed the SEARCH in your INCLUDE to show the proper site news.
--
PeterThoeny - 2011-05-02
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.