Forum OpenACS Q&A: Custom index for subsite

Collapse
Posted by Matthew Burke on

I've got an instance of acs-subsite mounted at /subsite. Under it I've got forums, news, etc moutned at /subsite/forums, /subsite/news etc. That all works fine.

I want to customize the page returned at /subsite. In addition to the normal behavior of listing the nodes mounted under /subsite, there are a few other things I need.

So I created a directory /www/subsite and copied the index* files from /packages/acs-subsite/www into it. The intent was to start from there and customize.

The problem is that even before I begin doing any customization, it bombs---the sql queries, which work fine normally, don't work when I copy the files over. Here's the top of the error trace:

Database operation "0or1row" failed (exception NSDB, "Query was not a statement returning rows.")
    while executing
"ns_pg_bind 0or1row nsdb0 {
    select acs_object.name(:package_id) from dual
}"
    ("uplevel" body line 1)
    invoked from within
"uplevel $ulevel [list ns_pg_bind $type $db $sql"
    invoked from within
"db_exec 0or1row $db $full_name $sql"
    invoked from within
"set selection [db_exec 0or1row $db $full_name $sql]"
    ("uplevel" body line 2)
    invoked from within 

I'll add that the query works fine if I go into psql and type it in by hand. I'm using the 4.6 release code.

Collapse
Posted by Tilmann Singer on
Most likely the query dispatcher does not find the right query and tries to execute the inline one in the index.tcl file, which does not work.

Did you try modifying the lines in the .xql file:

<fullquery name="dbqd.www.index.user_name_select">

to something like this:

<fullquery name="dbqd.www.subsite.index.user_name_select">

There was a bug in the query dispatcher related to this some time ago, which may still be there, but you should try that at least.

Collapse
Posted by Frank N. on
Tilmann, I'm having fun with precisely the same issue right now, and your suggestion doesn't work I'm afraid. Suggestions highly welcome.
Collapse
Posted by Frank N. on
PS: I'm using 4.6.1-beta1 from CVS. I hope this doesn't mean that subsites are broken for general use.
Collapse
Posted by Jarkko Laine on
This is a really good question, which I have too been thinking about some time. More generally, is the way Matthew has done the right way (tm) to go when you want custom front pages for any packages?

I think one probably wants to have a custom front page for subsite, but often this is also the case for some other package instance, such as forums.

Some documentation concerning these things would be very nice to have, as it's the ease of use in the real world that is going to make OpenACS more widely adopted.

Collapse
Posted by Frank N. on
I have posted this as bug #193 under ACS Subsite for now.

Jarkko, I'm interested in the customization issue as well. Seems the best and most flexible way for now is to have subsites within subsites for each group of package instances you want to share a common layout, but that does strike me as a bit of overkill.

An alternative could perhaps be to change a given package to inherit, say, bboard-master instead of the default master, but then you would have to provide and/or duplicate the template pieces in question for *all* subsites on your site, including the root.

I wonder if there is a way to detect from within Tcl what type of slave we have been called from. That would be a way of customizing the layout on both a per-package and per-subsite instance without having to change the core package.

Collapse
Posted by Robert Locke on
Regarding package specific customization, check out this proposal on the table for 4.7:

https://openacs.org/forums/message-view?message_id=63062

Regarding the original bug, I believe this has to do with "oacs_root/tcl/zz-postload.tcl" only loading query files within the "oacs_root/www" and "oacs_root/tcl" directories.  The hack is to change this line in "zz-postload.tcl":

set dirs {www tcl}

to:

set dirs {www tcl add_your_dirs_here}

The REAL answer is to probably recursively descend through the oacs_root/www hierarchy looking for and loading *.xql files.

Collapse
Posted by Robert Locke on
Collapse
Posted by Frank N. on
Thanks Robert, this works like a charm. I just tested it nested two levels deep.

Later today I will reclassify #193 to a doc suggestion, or just close it.

Collapse
Posted by Robert Locke on
Glad it helped Frank... I would still classify this as a bug though, or at minimum a feature request.  I think all *.xql files should be loaded underneath /www/, unless I'm missing something.
Collapse
Posted by Frank N. on
Well, all *.xql files below www are loaded, and it is possible to put the named queries for subsites into, say, index.xql in /www. I just checked it. However I find this solution a bit messy. IMHO it is more elegant to keep all files belonging to a particular subsite in a single directory, specified through the subsite parameter.

I will add an explanatory comment to the bug report, and let the powers that be decide what, if anything, should be done about it.

Collapse
Posted by Jeff Davis on
Frank, I will check in a fix for this tonight.  Its actually done and I am just testing it now.  I changed it so it walks the tree and finds all the .xql files in www and on down.
You don't need to do fully qualified query names either.

I can mail you the patch if you want to give me a hand making sure it works :)

Collapse
Posted by Frank N. on
Jeff, I would certainly not mind giving a hand with testing. Feel free to mail it to me, though I will go to bed in a few hours. I'm currently running 4.6.1-beta1. Let me know if I should use something different.
Collapse
Posted by Jeff Davis on
I went ahead and committed the patch to 4.6 and the head.
I did not update the 4.6.1-beta1 tag so you would need to
update to the oacs-4-6 tag in the tcl directory.
It's no longer necessary to fully qualify the
query names (it seems to all work correctly with simple
names and the correct full name is constructed).
Collapse
Posted by Matthew Burke on
Well thanks everybody for the help.  My (current) problem is all cleared up---clearly I need to check in with this forum more frequently since while I was busy teaching today I missed all your messages.

Right now I have the zz-postload file hand patched but tomorrow I'll put Jeff's patch into production and give it a thorough workout.