Embedded [Search] Context Snippets (Very Useful)

This WebDNA talk-list message is from

1998


It keeps the original formatting.
numero = 17809
interpreted = N
texte = One of the problems with using the search context ([search db=...][/search]) is that the search parameters are somewhat hard coded. This is really nice for certain parameters like max that you never want to change, but can be difficult to work with when you want to different search forms to point to the same page with the embedded search context.Rather than make the problem more complex by expanding the existing context and adding new features, this problem can be solved with some careful syntax (naming) changes and a clever use of the [formvariables] context.The Bay To Breakers search page (http://search.smithmicro.com/btb) uses this syntax. Included below are snippets of the WebDNA used on that page and an explanation of the syntax.

Search

Year
Name
Home
This is the basic search form. Note that all search variables are preceded by a set sequence of characters, in this case s_. Also note that the names of the various form variables are the actual search parameters themselves.[math]start[/math] - [math]start+999[/math]This link is another search form, very different from the form above, that searches the same database. It uses the same syntax to create the parameter names.[search db=btb.db&max=100&PLACEtype=number&asPLACEsort=1[showif [startat]![raw][startat][/raw]]&startat=[startat][/showif][formvariables name=s_&exact=f]&[url][getchars start=3][name][/getchars][/url]=[url][value][/url][/formvariables]] [numfound] runners found that match your search. [shownext] Show Results [start]-[end]
[/shownext] [/search]This is the actual (only) search context used to do the work. Note that the search parameter list starts with certain values that are hard-coded, values that I don't want someone to be able to override by typing their own parameters in a URL. The [formvariables] context is used to then enumerate all the search parameters, whatever they may be. Since the names all begin with s_, the [getchars] context is used to shorten them.Later, the [shownext] links are appropriately built with the startat parameter added at the end.Using this sort of naming scheme, I think you will find that the [search] context becomes more powerful and your pages become much cleaner.John. John A. Hill, V.P. Marketing Pacific Coast Software eCommerce / Web Developer Tools http://www.smithmicro.com Associated Messages, from the most recent to the oldest:

    
  1. Re: Embedded [Search] Context Snippets (Very Useful) (Kenneth Grome 1998)
  2. Re: Embedded [Search] Context Snippets (Very Useful) (John Hill 1998)
  3. Re: Embedded [Search] Context Snippets (Very Useful) (Kenneth Grome 1998)
  4. Embedded [Search] Context Snippets (Very Useful) (John Hill 1998)
One of the problems with using the search context ([search db=...][/search]) is that the search parameters are somewhat hard coded. This is really nice for certain parameters like max that you never want to change, but can be difficult to work with when you want to different search forms to point to the same page with the embedded search context.Rather than make the problem more complex by expanding the existing context and adding new features, this problem can be solved with some careful syntax (naming) changes and a clever use of the [formvariables] context.The Bay To Breakers search page (http://search.smithmicro.com/btb) uses this syntax. Included below are snippets of the WebDNA used on that page and an explanation of the syntax.

Search

Year
Name
Home
This is the basic search form. Note that all search variables are preceded by a set sequence of characters, in this case s_. Also note that the names of the various form variables are the actual search parameters themselves.[math]start[/math]%20[math]start+999[/math]>[math]start[/math] - [math]start+999[/math]This link is another search form, very different from the form above, that searches the same database. It uses the same syntax to create the parameter names.[search db=btb.db&max=100&PLACEtype=number&asPLACEsort=1[showif [startat]![raw][startat][/raw]]&startat=[startat][/showif][formvariables name=s_&exact=f]&[url][getchars start=3][name][/getchars][/url]=[url][value][/url][/formvariables]] [numfound] runners found that match your search. [shownext] [url][name][/url]=[url][value][/url]&[/formvariables]startat=[start]>Show Results [start]-[end]
[/shownext] [/search]This is the actual (only) search context used to do the work. Note that the search parameter list starts with certain values that are hard-coded, values that I don't want someone to be able to override by typing their own parameters in a URL. The [formvariables] context is used to then enumerate all the search parameters, whatever they may be. Since the names all begin with s_, the [getchars] context is used to shorten them.Later, the [shownext] links are appropriately built with the startat parameter added at the end.Using this sort of naming scheme, I think you will find that the [search] context becomes more powerful and your pages become much cleaner.John. John A. Hill, V.P. Marketing Pacific Coast Software eCommerce / Web Developer Tools http://www.smithmicro.com John Hill

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Download Question (1997) Frames and WebCat (1997) Updating a database once per day - An example (1998) Re:Realtime Transaction Processing (1999) Appending Information from one db to another (1998) WebCatalog [FoundItems] Problem - LONG - (1997) triggers (2003) why is this line in GeneralStore? (1998) addlineitems within formvariable loop (1998) More on the email templates (1997) Associative lookup style? + bit more (1997) Missing from Docs [folderName] (1997) Sub Totals (2000) Hummm .... (2002) Attn: Bug in GeneralStore example b15 (1997) More to Expire (1998) TCP Connect (1999) Next (1997) WebDNA - MySQL - PHP (2003) [WebDNA] Illegal character removal (2012)