This topic is locked

Modify Search Results

4/24/2013 11:10:56 AM
ASPRunnerPro General questions
H
heets author

Hi,

I have an application that tries to cater to multiple languages. Once section lists documents and I have made changes to the events of the list page (list page before sql query) so that the language selected results in displaying only the documents that are specific to that language. ( I have a field in the database that indicates the language of the document)
This is working well but when a visitor does a subsequent search all the languages are represented in the search results.
Is there a way to modify the strWhereClause before processing a search so that only the results of the search that are specific to a language will be displayed?
The application is running version 6.2 of asprunnerpro.
Thanks for your help.

Sergey Kornilov admin 4/24/2013

Sure, this can be done. You can build a custom WHERE clause based on current selected language which is stored in SESSION("language") session variable.
You can find some additional inspiration at http://xlinesoft.com/asprunnerpro/docs/localizing_asprunnerpro_application.htm

H
heets author 4/24/2013

Thanks for you quick response!
I've tried that by putting the following code in the "List page: Before SQL Query" event
If mlang_getcurrentlang() = "Spanish" Then

strWhereClause = "[Language]=""Español"""

elseif mlang_getcurrentlang() = "Russian" Then

strWhereClause = "[Language]=""Pусский"""

elseif mlang_getcurrentlang() = "German" Then

strWhereClause = "[Language]=""Deutsch"""

else

strWhereClause = "[Language]=""Eng"""

End If
This works great until the search function is used on the page. The search results include records from all languages. Do I have to put this code in somewhere else or modify this code to work so that search results will only include records with the corresponding language?

Sergey Kornilov admin 4/25/2013

This code doesn't look right to me as in SQL query you need to use single quotes i.e.

If mlang_getcurrentlang() = "Spanish" Then

strWhereClause = "[Language]='Español'"


Not sure what else it might be, you need to check examples in corresponding ASPRunnerPro manual.