Forum OpenACS Q&A: suppress errors in templates
More detail: I'm putting together a sort of dynamic templating system, where a template includes a list of other sub-templates, determined at runtime. The included sub-templates could of course do the same, and well, you get the idea. The list of sub-templates would come from the database, and the main template page would have something like:
However, if a particular subtemplate is not found, it outputs an error message "No script or template found for [whatever]". Obviously, the best thing is to prevent missing templates from getting into the include list, but just in case I'd like to prevent this ugliness from reaching users.
If the list of templates doesn't change after startup, then you could run this once and store the results with the subtemplates references.
When you reference a template in an include, you're using the file pathname reference.
Using your example, if subtemplates:item has a value of my-unique-template-for-this-one-user-this-afternoon then you could check for its existence by adding the openacs root dir to the filepath name:
\[file exists "\[acs_root_dir\]\$subtemplates:item\].tcl"
\[file exists "\[acs_root_dir\]\$subtemplates:item\].adp"
..the pathname might need some tweaking.. but there it is.
These could be scanned one at runtime, since you're defining the templates prior to startup.
FYI, depending on how you're doing this, you might be opening your system up to some security issues. You don't want to give users direct access to specifying template names.