I recently had to write some UI pages that I knew would be needed in at least two different locations in my application. I wanted the context bar, permissions and title to depend on the current location in the application, but the functionality would remain the same, and consist of a few display, edit, delete, confirm etc. pages that reference each other.
A solution that turned out to work quite well is the following:
- put all pages to reuse under package-key/lib/functionality-name/, e.g.:
package-key/lib/functionality-name/index.tcl
package-key/lib/functionality-name/add-edit.tcl
package-key/lib/functionality-name/add-edit.adp
...
- in the application where the functionality is needed, add a .vuh file like this: package-key/www/some/object/functionality-name.vuh.
- From within e.g. package-key/www/some/object/index use relative links to refer to the pages like this: href="functionality-name/add-edit".
- Add security check as needed to the functionality-name.vuh
- Set the location specific fragments of the context bar in the .vuh file
- build the context bar in the lib/ pages by lappending to that passed in context bar
- define and pass on all further variables that the lib/ pages need, e.g. title
- Call the lib/ pages in the .vuh like this:
rp_form_put context $context_fragments
rp_internal_redirect "/packages/package-key/funcionality-name/[ad_conn path_info]"
I think something like this would be useful for permissions and maybe parameter settings UI so that applications can make use of these functionalities without sending the user to a place out of context where there is no possibility to navigate back. Unless it turns out not to work for some reason or someone else is quicker, I'll try to add this at acs-subsite/lib/permissions/ after the release.