On Oct 12, 2011, at 12:04 PM, Peter Jakobsson wrote:

> This is exactly what I need as far as it goes but my customer wants the query 
> parameters streamlined as well. So what I need to do is parse the rest of the 
> URL (e.g. /type/product/name/ducted_fan_26_inch_radial) and have it end up as 
> regular query parameters when the request hits the handler
> 
> What I'd like to know is are there any example for this floating around or do 
> I just extend the handler myself by parsing the trailing pairs in the URL and 
> changing "type/product" to "type='product' and returning the result in the 
> OnRequest handler. (From there I assume they'll find their way into the 
> attributes collection of the Fusebox framework automatically).

You just have to write the code. Your url_factory can:

1. accept the query in the form " /type/product/name/ducted_fan_26_inch_radial" 
 and append it to the /circuit/action 
("circuit/action/type/product/name/ducted_fan_26_inch_radial")

2. If query does not start with "/", parse the query into the "/" version 
(replace ";" or "&" with "/", replace "?" with "/" or add slash)

In Active4D.a4l use modified form of parsing the factory url. You have to 
account for the normal stuff (.  in url, etc). then write something like:

$inQuery := a4d.web.collectionToQuery(_query)
// you should not have any for your scheme
if ($inurl[[-1]] = "/")
    $inurl := substring($inurl;1;length($inurl)-1)
end if
$cnt := split string($inurl;"/";$chunks)
// if $cnt is > 2, it better be an even number!
case of
    :($cnt = 0)
        return ("/index.a4d")
    :($cnt = 1) // controller only index. 
        $cir := $chunks{1}
        $act := "index" // or whatever your main action is
    :($cnt = 2) // circuit action only
        $cir := $chunks{1}
        $act := $chunks{2}
    else
       $cir := $chunks{1}
       $act := $chunks{2}
       for ($i; 3; $cnt;2 )
        _query{$chunks{$i}} := $chunks{$i+1}
       end for
end case
_query{fusebox.conf.fuseaction} := '$cir.$act'
return ("/index.a4d")

Not tested, but I've used techniques like this for years.


Steve
        


_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://vasudev.aparajitaworld.com/archive/active4d-dev/

Reply via email to