The Toolkit for Online Communities
17104 Community Members, 0 members online, 2395 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Q&A : url abstraction : One Message

Forum OpenACS Q&A: Re: url abstraction

3: Re: url abstraction (response to 1)
Posted by Tilmann Singer on
1. The term url abstraction is used in another sense in the openacs docs, as they use it to name the system of hiding the file extension in the url (/bla/message-post instead of /bla/message-post.tcl) This is used in all of openacs and it is quite cool. I'm just mentioning this to prevent (mostly my own) confusion.

2. I think it can't and shouldn't be done in a general way that works for all packages, but rather needs to be implemented in an application specific way for each package, like Tom's example for forums. There's also a running example in bugtracker.

3. Some minor remarks to Tom's example: you can also use [ad_conn path_info] instead of ad_conn urlv. And instead of ns_set put ... there is the handy rp_form_put proc (with which the deletion loop would also be obsolete I think).

5: Re: url abstraction (response to 3)
Posted by Tilmann Singer on
An important aspect of this is also that when a fancy url like this is enabled, it should also be changed in all places where the url is used within the package. E.g. after you created the possibility to say /forum/12345 you should use /forum-view?forum_id=12345 as seldom as possible (from within the package and other places of the toolkit) for consistency. Important among other reasons to not disturb the browser feature to display already visited links in a different colour.

Malte, the /o/12345 stuff is useful for building lists of objects of mixed type, where the computation of the url should be delayed, but it should in my opinion not be used for package internal links, because it results in an unnecessary http (external) redirect.

6: Re: url abstraction (response to 3)
Posted by Tom Jackson on

You need to delete all the forum_id query variables, then add the one you need. rp_form_put just appends a new query variable to the form. It puts it on the end, so the first value will be the original, if any.

For instance try the following link, which is setup like this:

ad_page_contract {
        @author tom jackson

set forum_id [lindex [ad_conn urlv] end]

rp_form_put forum_id $forum_id

rp_internal_redirect forum-view

rp_form_put test

The query variable is just appended, leading to the error message. You can't use replace, because this is equivalant of delkey and put. If there are more than one forum_id variables, the wrong one might be used. Also, replace is case sensitive, whereas the loop I'm using is case insensitive.

7: Re: url abstraction (response to 3)
Posted by Tom Jackson on

For the url '/test/12345/', [ad_conn path_info] returns '12345/', so that will not work.