parametrized more queries

and fixed a bug in search.tpl