Tags:
create new tag
, view all tags

Question

Hi!

%SEARCH% question: In the Main Web, I have (of course) the user topics, like AndreBonhote. Now I would like to create a topic which collects specific data from all the user topics. E.g., each topic has an entries like this:

  • Full Name: André Bonhôte
  • Pgp Key: 3076DFF3
  • Office Phone: +41 1 5 600 501

Now, on the PgpKeysAndPhoneNumbers topic, I'd like to have

Name PGP Key Office Phone
André Bonhôte 3076DFF3 +41 1 5 600 501
Other Guy 345DF344 +41 1 1 111 111

Is that possible? To be honest, I can't think of a way doing that right now. It would mean, take the user list, parse it and include all the topics appearing there with a regex.

Is there something out of the box, or do I have to write this plugin myself?

Thanks a lot!

André

PS: You're making my days with TWiki smile

Environment

TWiki version: TWikiBetaRelease2004x10x24
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: irrelevant
Web server: irrelevant
Perl version: irrelevant
Client OS: irrelevant
Web Browser: irrelevant
Categories: Search, Plugins, Add-Ons

-- AndreBonhote - 05 Nov 2004

Answer

See the RegisterCgiScriptRewrite which moves all user data into FormFields?

-- MartinCleaver - 05 Nov 2004

Hi Martin

Isn't that a bit of an overkill? Well, I didn't read the full page, but already the *Changes sections on the bottom look very frightning. I have already had a major upgrade on the wiki (which was quite a pain, cos we have changed a lot since we've used it). As well, I suppose this is in progress and not usable for production yet.

Another way anywhere?

TIA

André

-- AndreBonhote - 05 Nov 2004

A simple SEARCH with $pattern() will do it:

%SEARCH{ "* Full Name" nosearch="on" nototal="on" format="| $pattern(.*?\* Full Name\: *([^\n\r]*).*) | $pattern(.*?\* Pgp Key\: *([^\n\r]*).*) | $pattern(.*?\* Office Phone\: *([^\n\r]*).*) |" }%

Actual example searching on this topic only:

Name PGP Key Office Phone
André Bonhôte 3076DFF3 +41 1 5 600 501

-- PeterThoeny - 06 Nov 2004

You are certainly right in that this is still developmental code and will of course conflict if you have made extensive local changes.

Beware that pattern searches of the above type fail when users edit their change the format of their pages.

Can your local changes be submitted back to the codebase? Doing so will make your life easier if DakarRelease caters to your needs. See DevelopBranch for details. Thanks.

-- MartinCleaver - 06 Nov 2004

I have re-written the RegisterPub to have additional fields for the user to fill in. The "old" version of CGIRegister will take these and add them to the user's page when it gets gerated.

I've also edited the template used for generating the user's page so it has a few enhanced fields, a TOC ...

-- AntonAylward - 07 Nov 2004

The new version also has this behaviour, except that it will put all fields as formfields if there is a form attached to new user template. What I had wanted to do was get it to check to see whether that particular field was present, but at the time there was no API to do it.

Until my MartinCleaverWouldLikeToCheckIn request is granted I can't do any more.

-- MartinCleaver - 07 Nov 2004

Thanks for all the answers! Wow, I am really impressed about the search, alghough: I wouldn's say this is simple smile

Thanks a lot!

André (impressed and really happy now!)

-- AndreBonhote - 08 Nov 2004

Ehm .. quite happy smile I wanted to create nice View links for the PGP keys, but they look ugly when there's no such list entry. I tried around a bit with the %CALC%, to do something like

=%IF{"$NOT(LENGTH($pattern...)),,[Display Link])"}%, but with no success.

A shorter one showed that somehow the $pattern doesn't get passed to %CALC%:

%CALC{"$UPPER($pattern(.*?\* Pgp Key\: ([^\n\r]).*),''))"}%

The result is

$PATTERN(.*?\* PGP KEY\: ([^\N\R]).*),'')

As well, somehow it doesn't get rendered for each row of the table, but only for the last one.

What am I missing?

-- AndreBonhote - 08 Nov 2004

I am not exactly sure if I understand your question.

CALC executes before SEARCH, that is your $IF() test is done once for the SEARCH instead of once for each hit. That is also the reason why $UPPER() affects the pattern instead of the result of the pattern.

You need to defer the CALC in the format="" of SEARCH by escaping the percent signs of CALC with $percnt. Example:

%SEARCH{ .... format="$percntCALC{| $SET(var, $pattern(....))$IF($LENGTH($GET(var)), do something if set such as $GET(var), else something else) | .... |}$percnt" }%

What it does: First assign the result of the pattern to a variable. Then output text conditionaly based on the value of the variable. Repeat this for each cell.

-- PeterThoeny - 09 Nov 2004

Wow, that one works now ... It's not that obvious, though ... is this documented somewhere?

Yeah, I agree, my posting up there was not really clear. Sorry for that.

-- AndreBonhote - 09 Nov 2004

 
Topic revision: r13 - 09 Nov 2004 - 09:45:58 - AndreBonhote
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback