Index: openacs-4/packages/acs-core-docs/www/tutorial-vuh.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/tutorial-vuh.html,v diff -u -N -r1.13.2.1 -r1.13.2.2 --- openacs-4/packages/acs-core-docs/www/tutorial-vuh.html 10 Jun 2009 22:24:09 -0000 1.13.2.1 +++ openacs-4/packages/acs-core-docs/www/tutorial-vuh.html 11 Sep 2009 23:41:28 -0000 1.13.2.2 @@ -1,6 +1,6 @@ - -Using .vuh files for pretty urls

Using .vuh files for pretty urls

.Vuh files are special cases of .tcl files, used for rewriting incoming urls. We can use a vuh file to prettify the uri for our notes. Instead of note-edit?item_id=495, we can use note/495. To do this, we will need a new .vuh file for redirection and we will need to change the referring links in note-list. First, add the vuh:

[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ cd /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/www
-[$OPENACS_SERVICE_NAME www]$ emacs note.vuh
+
+Using .vuh files for pretty urls

Using .vuh files for pretty urls

.Vuh files are special cases of .tcl files, used for rewriting incoming urls. We can use a vuh file to prettify the uri for our notes. Instead of note-edit?item_id=495, we can use note/495. To do this, we will need a new .vuh file for redirection and we will need to change the referring links in note-list. First, add the vuh:

[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ cd /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/myfirstpackage/www
+[$OPENACS_SERVICE_NAME www]$ emacs note.vuh
 

Paste this into the file:

# Transform requests of type: a/b
 # into this internal request: A?c=b
 # for example, note/495 > note-edit?item_id=496
@@ -15,10 +15,10 @@
 
 rp_form_put item_id $request
 
-set internal_path "/packages/[ad_conn package_key]/www/note-edit"
+set internal_path "/packages/[ad_conn package_key]/www/note-edit"
 
 rp_internal_redirect $internal_path
-

We parse the incoming request and treat everything after the final / as the item id. Note that this simple redirection will lose any additional query parameters passed in. Many OpenACS objects maintain a pretty-name, which is a unique, human-readable string, usually derived from title, which makes an even better 'pretty url' than a numeric id; this requires that your display page be able to look up an item based on pretty id.

We use rp_form_put to store the item id in the internal register that the next page is expecting, and then redirects the request in process internally (ie, without a browser refresh).

Next, modify note-list so that its link is of the new form.:

[$OPENACS_SERVICE_NAME www]$ emacs ../lib/note-edit.tcl
+

We parse the incoming request and treat everything after the final / as the item id. Note that this simple redirection will lose any additional query parameters passed in. Many OpenACS objects maintain a pretty-name, which is a unique, human-readable string, usually derived from title, which makes an even better 'pretty url' than a numeric id; this requires that your display page be able to look up an item based on pretty id.

We use rp_form_put to store the item id in the internal register that the next page is expecting, and then redirects the request in process internally (ie, without a browser refresh).

Next, modify note-list so that its link is of the new form.:

[$OPENACS_SERVICE_NAME www]$ emacs ../lib/note-edit.tcl
 db_multirow \
     -extend {
 	edit_url
@@ -30,8 +30,8 @@
                mfp_notesx n
         where  n.revision_id = ci.live_revision
     } {
-	set edit_url [export_vars -base "note/$item_id"]
-	set delete_url [export_vars -base "note-delete" {item_id}]
+	set edit_url [export_vars -base "note/$item_id"]
+	set delete_url [export_vars -base "note-delete" {item_id}]
     }
 

You may also need to change some of the links in your package. Commonly, you would use ad_conn package_url to build the