Forum OpenACS Q&A: Using an .adp template with a .vuh page

Collapse
Posted by Lars Pind on
Has anybody figured out how to use an .adp template with a .vuh page?

I'm trying to implement an archive page for my new weblog over at
http://www.pinds.com. I want you to be able to say
http://www.pinds.com/blog/archive/2002/02/ to get the archive for
all of February, or http://www.pinds.com/blog/archive/2002/02/27/ to
get the archive for today.

The obvious attempt would be to have an index.adp next to the
index.vuh, and simply say "ad_return_template" at the end of the
script, but it doesn't work: Nothing gets sent to the browser.

I've tried to look at the acs-templating code and see if I could
figure out some obvious way to do it, without any luck. So far I've
been unwilling to go through and try to decipher all of the code.
While I'm a big fan of the way the templating system generally
works, I'm not a big fan of the way it's implemented.

Any luck, anyone?

Collapse
Posted by Stephen . on
set path [string trimright [ad_conn file] index.vuh]
rp_serve_abstract_file [append path "my-template"]
Collapse
Posted by Lars Pind on
Hm. Didn't work, either. It seemed like things didn't get evaluated in the right stack frames, or something like that. Oh, well, too many other things on my plate than fighting the implementation details of the templating system.
Collapse
Posted by Stephen . on
Sorry, that was a quick cut 'n paste, untested. My actual set-up is:
# www/tmp/index.vuh
set path [string trimright [ad_conn file] index.vuh]
rp_serve_abstract_file [append path "virtual"]

# www/tmp/virtual.tcl
set urlv [ad_conn urlv]
ad_return_template

-- www/tmp/virtual.adp
<master>
<h1> @urlv@ </h1>
The real work of serving the request is pushed off to the virtual.tcl/adp pair so that the template can be different than that used for index.tcl without breaking the convention that code/template pages are similarly named. My bad...
Collapse
Posted by Richard Hamilton on
I thought it would be a good idea to serve up the root index page of a site through Edit-this-page to enable users/admin to update content and I wanted to retain the "You are currently logged in as.." functionality that is included in the OpenACS index page following a new install.

I can see that Stephen's solution will work for returning a .tcl/.adp page pair from the file system, but has anyone yet worked out how to include the contents of tcl vars in a page served from Edit-this-page - (or am I just getting too ambitious here!?).

Regards
Richard

Collapse
Posted by Tilmann Singer on
The thread above is quite old - the correct answer to it today would be to use

rp_form_put x $x
rp_internal_redirect my-template

Where my-template could refer to a single file my-template.adp, which would display the content of the variable x if it contains @x@.

I am not quite sure what you are asking though ..

Collapse
Posted by Richard Hamilton on
Thanks for clarifying the use of rp_form_put. What I am asking is whether/how I can include @var@ type references in pages served by the Edit-This-Page module.

i.e. ETP root mounted on /content and index.vuh in web root at / so that when http://www.bloggs.com is requested the request processor serves /content/index via the ETP application. So the page is an ETP served page from the database wrapped in defaultmaster.adp. My question is then how to I include variables from a .tcl script in the part of the page that was served by the ETP app?

Regards
Richard

Collapse
Posted by Jade Rubick on
Currently, I don't think you can do this without some hacking. I'd ping DaveB about this... I tried doing this once. There may be a way to do it.