When you build the links, do something like:

{{for suggestion in suggestions:}}
{{=LI(A(suggestion, _href=URL('default', 'resultsDisplay', 
vars=dict(userQuery=suggestion))))}}
{{pass}}

That will give you URLs like 
/yourapp/default/resultsDisplay?userQuery=suggestion. The suggestion will 
then be accessible as request.vars.userQuery in the resultsDisplay function.

Anthony

On Thursday, July 26, 2012 5:52:34 PM UTC-4, adohertyd wrote:
>
> How do I assign the query value to the request.vars? I'm ok with checking 
> for it in the function, but how do I pass the request.vars to the function 
> first??
>
> On Thursday, 26 July 2012 22:31:54 UTC+1, Anthony wrote:
>>
>> Construct the links so they contain a query string with the new 
>> userQuery. In the resultsDisplay function, check for a userQuery in 
>> request.vars, and if present, process that value instead of processing 
>> session.userQuery.
>>
>> Anthony
>>
>> On Thursday, July 26, 2012 4:21:22 PM UTC-4, adohertyd wrote:
>>>
>>> I posted a related question earlier but given the response I don't think 
>>> my question was clear. My index page contains a form and the index() 
>>> function assigns the user input in this form to a variable: 
>>> session.userQuery
>>>
>>> session.userquery is then processed in resultsDisplay() and sent to a 
>>> number of API's. The data returned from these API's is processed and 
>>> displayed on resultsDisplay.html. On results.html the user is given 
>>> suggestions for an alternative term. This is where my query lies.
>>>
>>> I want the generated suggestions to be clickable links that will restart 
>>> the resultsDisplay() function with the clicked term as the new 
>>> session.userQuery value. The results generated will then be relative to the 
>>> new term. I hope this makes sense. As I've said, it's like when a user 
>>> misspells a word in Google and they ask "Did you mean...." and when you 
>>> click the suggested term, the suggested term replaces the user's original 
>>> input.
>>>
>>> *def index():*
>>>   
>>>   #assigns user input to session.userQuery
>>>
>>>
>>> *def resultsDisplay():*
>>>    
>>>  #processes session.userQuery
>>>     #sends processed string to number of API's
>>>     #processes API returns
>>>     #returns data
>>>
>>>
>>> *resultsDisplay.html: *  
>>>  
>>>  Results:
>>>    <ul>
>>>         <li> results </li>
>>>   </ul>
>>>
>>>  Suggestions:
>>>    <ul>
>>>         <li><a href="resultsDisplay.html" onclick=session.userData=
>>> "suggestion"> suggestions</a> </li>
>>>    </ul>
>>>
>>>

-- 



Reply via email to