[ic] Problem re-using search data containing spaces

Steve interchange at bojanglesdesign.co.uk
Mon Oct 11 10:45:11 EDT 2004


I included the parsed HTML to show that only '%20' (not '%2520') is in
'mv_searchspec' when the form is submitted. So it is after the form has been
sent that it changes.

The code to retrieve the previous search data and create the form is quite
bulky, but uses the following script I found posted in the mail archives:

    [seti lastsearch][data session last_search][/seti]
    [perl]
      my @sf;
      my @se;
      my $item;
      my $cnt = 0;
      my $tmpSearch = {};
      my @searchstring = split(/\//,$Scratch->{lastsearch});
      ## build list of sf and se
      foreach $item (@searchstring) {
        if ($item =~ /^sf=(.*)/) {
          push @sf,$1;
        }
        elsif ($item =~ /^se=(.*)/) {
          push @se,$1;
        }
      }
      ## now build our hash of field/term pairs
      foreach $item (@sf) {
        $tmpSearch->{$item} = $se[$cnt];
        $cnt++;
      }
      ## populate needed scratch values
      $Scratch->{lastpublisher} = $tmpSearch->{publisher};
      return;
    [/perl]

The scratch value containing the previous publisher is then inserted into
the form with:
 <input type="hidden" name="mv_searchspec" value="[scratch lastpublisher]">

Perhaps I need to apply a filter to the scratch value to change the '%20' to
a normal space? But I haven't been able to find a filter which does this,
and my perl knowledge is very sketchy.

Many thanks

Steve

> From: "Ed LaFrance (New Media E.M.S.)" <ic_users at newmediaems.com>
> Reply-To: interchange-users at icdevgroup.org
> Date: Mon, 11 Oct 2004 07:17:36 -0700
> To: interchange-users at icdevgroup.org
> Subject: Re: [ic] Problem re-using search data containing spaces
> 
> At 06:20 AM 10/11/2004, you wrote:
> 
>> Hello,
>> 
>> I have a one-click search on my product page to allow users to easily search
>> for more products by the same publisher:
>> 
>> Search: [page search="
>> sf=publisher
>> se=[item-field publisher]
>> ml=20
>> tf=title
>> su=1
>> "][item-field publisher][/page]
>> 
>> After this search is issued, there is a drop-down form box on the results
>> page where users can chose to re-sort the data by another field.
>> 
>> <form action="/cgi-bin/bookshop/search.html?id=..." method="GET">
>> <input type=hidden name=mv_session_id value="...">
>> <INPUT TYPE=hidden NAME=mv_searchtype VALUE=db>
>> <INPUT TYPE=hidden NAME=mv_matchlimit VALUE=20>
>> <input type=hidden name=mv_substring_match value=1>
>> <input type="hidden" name="mv_search_field" value="publisher">
>> <input type="hidden" name="mv_searchspec" value="Penguin%20Books">
>> 
>> <select name="mv_sort_field" size="1">
>> <option value="title">title</option>
>> <option value="author" selected>author</option>
>> <option value="publisher">publisher</option>
>> <option value="category">category</option>
>> </select>
>> 
>> <input type="submit" name="submit" value="Go">
>> </form>
>> 
>> However, if the 'publisher' name contains a space, the space is converted to
>> a '%20' - which then seems to be changed to '%2520' when the re-sort search
>> is issued.
>> 
>> So the search returns no matches and the 'GET' url contains
>> 'http://...&mv_searchspec=Penguin%2520Books'
>> 
>> I would be grateful if someone could offer any advice on how I could prevent
>> the '%20' from being converted to '%2520'.
>> Or should I be looking to remove the initial '%20' from the hidden form
>> field in the drop-down list search?
>> 
>> I am currently running Interchange 5.0
>> 
>> Many thanks
>> 
>> Steve
> 
> You posted the parsed HTML of the searchbox, but what does the ITL look like?
> 
> - Ed
> 
> 
> ===============================================================
> New Media E.M.S.              Technology Solutions for Business
> 11630 Fair Oaks Blvd., #250   eCommerce | Consulting | Hosting
> Fair Oaks, CA  95628          Ed.LaFrance at newmediaems.com
> (916) 961-0446                http://www.newmediaems.com
> (866) 519-4680 Toll-Free      (916) 961-0447 Fax
> ===============================================================
> 
> _______________________________________________
> interchange-users mailing list
> interchange-users at icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
> 



More information about the interchange-users mailing list