Forum OpenACS Q&A: access changed cr_templates and add extra vars

I am figuring out cr_templates. I stored one in CR, accessed it through index.vuh and have edited it with BCMS-UI.

The problem that occurs is that when the content is changed in CR it is not accessible through content::init (index.vuh), because content::init writes the template out as an .adp/.tcl pair, but doesn't update this pair if the template in CR changes. It just checks if the file exists, AFAICT. It doesn't track difference between the file and CR.
Am I missing something?

One other thing. I would like to set extra variables in the template-name.tcl. How can I do that? Is there a template attribute that I can use? Currently I'm adding "source ../extra_template_vars.tcl" to template-name.tcl to pass the variables in. I was thinking of an attribute that would hold the (optional) name of a file that needs to be sourced.

Collapse
Posted by Dave Bauer on
You need to publish the template to the filesystem after it is changed. I think the procedure is item::publish. If you are using BCMS-UI there might be a different procedure you need to use.

Also you can substitute any tcl file you want for the tcl part of the template. Content::init only writes the tcl file if one does not exist.

I would recommend writing your own tcl script for the template.

Collapse
Posted by xx xx on
hmm, it doesn't look like item::publish is the one. I need to dig, I think.

Does XCMS have a "publish template" option? I cannot check since I get an error when I try to access it after install.

If I need to create a custom template-name.tcl and I need to publish the template, will the publish proc just replace .adp and not .tcl ?

Collapse
Posted by Dave Bauer on
Yes, XMCS-UI publishes the template. Under xcms-ui/manage/template there should be a script to publish a template.

And yes, it will only publish the ADP. There isn't any CR way to manage a tcl script. I think eventually we need to have Tcl procedures that can be dispatched according to the content type when a template is served. But that isn't going to help you today :)

Collapse
Posted by xx xx on
Thanks, I will try to get xcms-ui going.