Forum OpenACS Q&A: general comments on multiple subsites

Collapse
Posted by Vinod Kurup on
Hello OpenACS'ers!

I have a site with 2 subsites - the Main Site (at kurup.org) and Subsite1 (at kurup.org/subsite1).

I want to have general comments available on packages on both subsites, but I want general-comments to use the proper master template depending on which subsite it's in. But general-comments is a singleton package, so no matter what, it uses my Main Site master template.

I found Dave's comment from a couple years ago which seems to address this question. What is the proper approved way to do this?

Collapse
Posted by Vinod Kurup on
I think I've got GC to work with multiple subsites.

First: Mount GC in the subsite that I want

  1. go to /subsite1/admin/site-map
  2. add a folder under /subsite1, name it gc
  3. click mount
  4. scroll down until you see the Main site's general comments package and click on it
Second: fix the proc that figures out which general-comments package to use
in general-comments-procs.tcl, replace the general_comments_package_url proc with this one:
ad_proc -public general_comments_package_url {
   {-url "/"}
} {
   Returns a url pointing to the mounted general-comments package.
   Uses util_memoize for caching.
} {
   # find the closest subsite
   set subsite_node_id [site_node::closest_ancestor_package -url $url \
         -package_key acs-subsite \
         -include_self \
         -element node_id]

   # loop upwards until we find a gc package
   set gc_url ""
   while { [empty_string_p $gc_url] } {
       set gc_url [site_node::get_children -package_key general-comments \
            -node_id $subsite_node_id]
       set subsite_node_id [site_node::closest_ancestor_package -url $url \
            -package_key "acs-subsite" \
            -include_self \
            -element node_id]
       # vk: need to check if we go into infinite loop here
   }
   return $gc_url
}
This proc now takes a parameter (url) and finds the closest GC package url.
Third. go through and change any place that calls general_comments_package_url to add a parameter passing in the current url. There are a few in general-comments-procs.tcl, 1 in general-comments/www/test.tcl and 1 in lars-blogger/www/entry-chunk.tcl. There may be others, so do a grep search.

I'm not sure if this is the best way to do this, but it seems to work so far.