Re: Embedded [Search] Context Snippets (Very Useful)

This WebDNA talk-list message is from

1998


It keeps the original formatting.
numero = 17812
interpreted = N
texte = Hi John,Thanks for the code snippets! :)Question 1 - What's the action=search parameter for? It's not used in the search, so are you possibly using it for something else? Like a showif context that's in your template but not included in your snippets perhaps?Question 2 - Maybe I am misinterpreting something, but I don't understand how your s_ and [getchars] technique is going to prevent someone from changing one of the parameters in the URLs. It seems to me that the only way to really keep URL parameters from being changed is to hard-code them into the search context.Comment - You don't have to put the &startat=[startat] inside a showif context (in your search context). WebCat starts with 1 whenever startat = anything other than a number. It only starts at some other index value when the startat value is actually a number ...By the way, Congratulations! 2589 out of 44895 is in the top 6 percent! :) >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 Sincerely, Ken Grome 808-737-6499 WebDNA Solutions mailto:ken@webdna.net http://www.webdna.net 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)
Hi John,Thanks for the code snippets! :)Question 1 - What's the action=search parameter for? It's not used in the search, so are you possibly using it for something else? Like a showif context that's in your template but not included in your snippets perhaps?Question 2 - Maybe I am misinterpreting something, but I don't understand how your s_ and [getchars] technique is going to prevent someone from changing one of the parameters in the URLs. It seems to me that the only way to really keep URL parameters from being changed is to hard-code them into the search context.Comment - You don't have to put the &startat=[startat] inside a showif context (in your search context). WebCat starts with 1 whenever startat = anything other than a number. It only starts at some other index value when the startat value is actually a number ...By the way, Congratulations! 2589 out of 44895 is in the top 6 percent! :) >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 Sincerely, Ken Grome 808-737-6499 WebDNA Solutions mailto:ken@webdna.net http://www.webdna.net Kenneth Grome

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:

Orderfile (2005) frames & carts (1997) Hiding HTML and page breaks (1997) Need some assistance. (1999) Members register & gain access system (1998) Triggers (2003) Newbie problem blah blah blah (1997) WC2f3 (1997) How true is this? (1999) Non HTML file protection - OS X (webstar or apache) (2002) taxTotal, grandTotal (1997) Email template names (1997) Browser security type (2000) Erotic Sites (1997) searching by date (1998) Card clearance, problems - solutions? (1997) ASP and WebDNA (1998) database problem (2003) OT: javascript help (2003) WebCat2 - Getting to the browser's username/password data (1997)