Forum OpenACS Development: Re: URL abstraction in oacs 3.4

Collapse
Posted by Tom Jackson on
I'm guessing what you want is for users to visit the url path of /package/somename and then serve them /package/page?id=1234.

I can't figure out why you couldn't use an index.vuh file for this, unless one already exists for another purpose.

One complication is that if you use a .vuh file, you need to do a tiny amount of work before you can do a rp_internal_redirect. Here is an example page which does a url to query translation prior to doing the internal redirect:

ad_page_contract {

        Used Lab Equipment Searcher

} { {terms:trim ""}

} set urlv [ad_conn urlv] set urlc [ad_conn urlc]

set search "" set termCount 0 set title_words [list]

set mainkey [lindex $urlv 1] ns_log Notice "mainkey: $mainkey, urlv: $urlv"

if {[string eq "search" "$mainkey"]} { set urlv [split $terms] }

switch -exact -- $mainkey { "all" - "" { } "permalink" { set id [lindex $urlv end] rp_form_put ids.$id $id set title [db_string contentTitle " select content_title from cams_content where content_id = :id" -default ""] rp_form_put title $title } default { foreach original_term $urlv { set term $original_term if {[string match "*s" $term]} { set term [string range $term 0 end-1] } if {[string eq "lab" $term]} { continue } else { incr termCount lappend title_words $original_term set term "'%[string toupper [string map {' '' $ "" [ ""} $term]]%'" if {$termCount == 1} { append search "\n UPPER(\$column) like $term" } elseif {$termCount > 4} { break } else { append search "\n\$JOINER\n UPPER(\$column) like $term" } } } set title [join $title_words " : "] set JOINER "AND" set column content_title set FIRST_MATCH [subst $search] set sql " select content_id from cams_content where content_type_id = 472" set complete_sql "$sql AND $FIRST_MATCH" rp_form_put title $title set i 0 db_foreach "select_content_ids" $complete_sql { rp_form_put ids.$content_id $content_id incr i } if {$i == 0} { set JOINER "OR" set FIRST_MATCH [subst $search] set complete_sql "$sql AND $FIRST_MATCH limit 20" db_foreach "select_content_ids2" $complete_sql { rp_form_put ids.$content_id $content_id } } } }

rp_form_put content_type_id 472 set template "/packages/cams/www/one/one"

rp_internal_redirect "$template"