Forum OpenACS Improvement Proposals (TIPs): Re: Tip #18 (Proposed): search order for master tag

Collapse
Posted by David Cotter on
I hadn't heard of cofax - what's it like? I used this method in Openacs 3.x where ad_header and ad_footer search for templates based on the request URL. The header and footer template files were named: default, index, bboard.index, bboard.q-and-a-fetch-msg etc. and it finds the nearest match so /bboard/q-and-a-fetch-msg.tcl uses bboard.q-and-a-fetch-msg but /bboard/q-and-a.tcl uses default since there's no match. I found it to be very effective.
Collapse
Posted by Vinod Kurup on
For the record, I think this is a useful proposal and I've created a patch which implements it.

Say the web browser requests foo.adp. If foo.adp's master tag has a src attribute, that file is used as the master template. If foo.adp's master tag has no src attribute, then the current directory is searched for a master.adp file. If one is found, it is used as the master template. If not, then we go one directory up and look again. We keep going up until we find master.adp. If we get to the serverroot without finding one, then we use the master specified in the DefaultMaster parameter.

Now, if the master template that we find also has a master tag in it, then we include whatever we have now (foo.adp + local master.adp) inside DefaultMaster. Note, that we don't look up to the next directory in this case. Confusing, I know.

Here's an example.

/www/content/computer/foo.adp
foo.adp has a <master> tag with no src attribute, so it searches for /www/content/computer/master.adp. Lets say it's not there. It then goes up 1 directory and finds /www/content/master.adp. It dutifully includes all of foo.adp inside the <slave> tag that is in /www/content/master.adp. But we're not done yet because /www/content/master.adp happens to have its own <master> tag. So, we include everything we have and stick in the DefaultMaster's <slave>. Another (better) approach would be to take everything we have and look for the next most local master.adp (i.e. /www/master.adp). I couldn't figure out an easy clean way to do that. Within the scope of the <master> tag, you only have access to the file being requested, not the file being parsed. So it's hard to know which level of the master hierarchy we are at. Perhaps there's a way to do it inside template::adp_parse, but I'd have to do some more research or get help from the templating gods.

The current patch fits my needs, but I could see value in having even more flexibility.

Collapse
Posted by Jeff Davis on
If we do implement this we should probably cache the lookups if PerformanceModeP is set. I suspect walking up the tree doing 4 or 5 stats per page served would not be great on a production system.