Joel Burton wrote:
Part of my criteria for a site is to eliminate ugly URLs where possible. So, instead of
http://foo/authors/search?name=plath
I'd like
I've handled this (mishandled this?) with a SiteAccess scipt in the authors folder:
<dtml-comment> Handle author searches like /authors/plath without ugly URLs like /author/search?name=plath
Look at every request in this folder: if it's not for an existing file, then mangle it so that it becomes a request for the detail page, and set 'author' to the rest of the path </dtml-comment>
<dtml-let addon="REQUEST.path[-1]"> <dtml-if "addon not in objectIds() and addon[0:6] != 'manage'"> <dtml-call "REQUEST.path.pop()"> <dtml-call "REQUEST.path.append('detail')"> <dtml-call "REQUEST.set('author',addon)"> </dtml-if> </dtml-let>
(if there is a request for something that isn't actually in this folder, and isn't a manage request, mungle it)
Two questions:
1) is this terribly evil? is my site going to catch on fire one day because of this?
2) my breadcrumbs no longer work. I'm using one of the standard breadcrumb tips that runs off PARENTS, and it only shows 'Home > Authors', not 'Home > Authors > Plath' (which makes sense--Plath isn't on the PARENTS list.)
However, if I add the requested author name to PARENTS (via append), everything goes haywire -- I can no longer see the ordinary stuff, like standard_html_header
I could have a different breadcrumb routine in this folder, but that seems icky and hard to maintain. I'd rather figure out some way of getting the regular breadcrumb method to work properly here.
Any ideas?
As always, thanks for any help,
-- Joel Burton <jburton@scw.org> Director of Information Systems, Support Center of Washington
Another less code intensive way to do this would be to make search a Python script instead of a folder. If you go to the bindings tab of the script, you will notice an item called "Subpath". This lets you pass the portion of the URL after the script id as a list argument to the script. By default, the subpath information is passed in as the "traverse_subpath" variable. This python snippit could get you started: if traverse_subpath: author = traverse_subpath[0] ...Search Code Goes Here... -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>