Tuesday, October 09, 2007

How (and Why) to Use Different Search Templates for Different Lotus Domino Views

Why would you need to do this?
Until recently, I'd have been at a loss to give you a good reason. Now however, since I've decided to modify some databases for Mobile Phone use, I have a very good reason.

Suppose that you want your database to be searchable via the web and also searchable via mobile.
  • On the web, you can afford to spread out on the screen and you want to use a lot of fancy graphics and fonts.

  • On the mobile, you need to keep things as small and as plain as possible.

Working with your existing Database
Your database probably already has a $$SearchForm (or similar) and a $$SearchTemplateDefault. Leave these as they are and your web site will continue to work beautifully.

Make a copy of the two forms and modify them for mobiles

In these examples, we'll call...
  • the new $$SearchForm, MSearchForm

  • We'll call the new $$SearchTemplate for MSearchAll

On your MSearchForm, you need only have;

1. An Editable Text Field (called SearchWord1)
2. A Button
3. A Computed Text Field called $$Return

The formula for the button could be as follows;

DB:= @Implode(@Explode(@Text(@Subset(@DbName;-1)); "\\");"/");

SearchURL := "/"+DB+"/MSearchAll?searchView&query="+@Trim(SearchWord1);
ReturnURL :="/"+DB+"/MSearchAll?OpenView";

@Trim(SearchWord1) != "" ;
@URLOpen(SearchURL) ;

The formula for the $$Return Field could be as follows;
Note: HTML Brackets have been replaced with curly braces

"{script language=\"javascript\"}" +
"document.forms[0].Search.click();" +

(Actually I'm not sure you need this code on the mobile, but it's better to be safe than sorry).

Creating the Search View
You should now create a view and give it an alias of MSearchAll

If you're doing this for use on a mobile, you should make your view really simple and small (eg: Default Sans Serif 8 Points).

You won't need any categorizations here, just keep it as simple as possible (a list of titles only perhaps?)

Testing your Search
Once everything is saved, you can test your new search facility.

The URL would be something like;

(obviously this is a dummy url which won't work)

No comments: