Hi Gustaf,
As I've mentioned the foreach statement is a bottleneck for scalability.
Indeed title isn't the best for usual scenarios (i.e. where name is stable, cleaned from special chars and recommended).
However, title's behavior is precisely what I want to achieve aligned with SEO mutable pretty links. They're very dynamic.
Changes in item titles reflects in the keywords and metatags for SEO within the source code.
Still, your code is too specific and there's a bug when it exits 2 items, different content_types, with the same title.
Sometimes, I think it's better to have content_type splited and checked. In separated dbs_ But I still haven't thought this through.
By the way, I've noticed you didn't write ns_register in your chunk of code. Aren't they mandatory?
set query [ad_conn url]
set request [string range $query [expr [string last / $query] + 1] end]
#rp_form_put item_id $request
ns_log Notice "REQUEST $request"
set item_id [db_string select_item_id {
SELECT item_id FROM ee_venuesx WHERE url = :request
} -default 0]
if {$item_id eq 0 } {
set item_id [db_string select_item_id {
SELECT item_id FROM ee_servicesx WHERE url = :request
} -default 0]
}
if {$item_id ne 0 } {
rp_form_put item_id $item_id
}
set internal_path "/packages/[ad_conn package_key]/www/item-edit"
rp_internal_redirect $internal_path