Question
I am confused.
At my company Fooco, everyone's TWiki ID is created from their corporate user ID with the an initial cap and the standard suffix, Fooco.
So my WIKINAME is
VbrownFooco.
I want to do a search on our team directory pages (one per team membe) that will bring back only my name, using my WIKINAMER as input.
I expected this to work:
<!--
* Set MYID=%CALC{$TRIM( $LOWER( $SUBSTITUTE(%WIKINAME%,Fooco,)))}%
-->
%SEARCH{search="META:FIELD.*?PersonName.*?;META:FIELD.*?CorpID.*?%MYID%.*" topic="TeamContactPage.*" \
nosearch="on" regex="on" format=" [[$topic][$formfield(PersonName)]]" }%
It didn't. But this did:
%SEARCH{search="META:FIELD.*?PersonName.*?;META:FIELD.*?CorpID.*?%CALC{$TRIM( $LOWER( $SUBSTITUTE(%WIKINAME%,Fooco,)))}%.*" \
topic="TeamContactPage.*" nosearch="on" regex="on" format=" [[$topic][$formfield(PersonName)]]" }%
Can someone help me to understand why?
Environment
--
VickiBrown - 09 Jun 2007
Answer
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.
I can't say exactly why that wouldn't work, however, I can offer an alternative. I'm assuming you'd like to be able to have an input box that you can type in the name of the user and have it return the page you're looking for or something like that. If not, eh, good guess anyway
The first example is just another way of setting the variable outside the search statement. The second is a way of using an input variable as a search parameter.
1.
Set the value with:
<!--
%CALC{$SET(myID, $TRIM( $LOWER( $SUBSTITUTE(%WIKINAME%,Fooco,))))}%
-->
Then call it in the search with:
%SEARCH{search="META:FIELD.*?PersonName.*?;META:FIELD.*?CorpID.*?%CALC{$GET(myID)}%.*"
2.
Grab the value with:
<form action="%SCRIPTURLPATH{view}%/%TOPIC%">
<input type="text" name="myID" size="20" value="%URLPARAM{"myID" default=""}% /> <input type="submit" value="Get Me" />
</form>
Then call it in the search with:
%SEARCH{search="META:FIELD.*?PersonName.*?;META:FIELD.*?CorpID.*?%URLPARAM{"myID" default="VickiBrown"}%.*"
The default value for the URLPARAM doesn't actually need to be there, but it does allow you to make the search work the first time around with some constant value. I put a URLPARAM in the value property of the text box as well, so that it will retain the value you searched for once you run the search. This can be omitted if unnecessary.
I hope this helps. If this isn't exactly what you were looking for, let me know and I'll see if I can help further.
--
MatthewCardozo - 26 Jun 2007
Closing this question, it is over 30 days old.
--
PeterThoeny - 12 Aug 2007