Forum OpenACS Q&A: Newbie Alert: ADP vs TCL

Collapse
Posted by Rick Cottle on
Still working my way through the problems sets, and looking at all possible sites for ideas and implementation examples, and have a basic question

What is the basic difference (aside from the extensions) between ADP and TCL scripts in the OpenACS environment?

Collapse
Posted by John Lowry on
You can think of .adp as a web page with embedded Tcl code, and .tcl as the reverse (Tcl script with embedded HTML/text output).

So you can use either one, but if you have more HTML than Tcl you'll find it more convenient to use .adp, and vice versa.

If you're writing .adp, you have to enclose the Tcl in special tags. If you're writing .tcl you have to explicitly write the HTML/text output to the client connection (eg. using ns_write. You have to remember to quote the double quotes within .tcl output.

The aolserver web site has more details.

Good luck with the problem sets.

Collapse
Posted by David Walker on
.adp starts it's life as an html page and then code is added in (you can simply rename and .html page to .adp and have a working .adp page that doesn't do anything special)
for example:
<%
set somevar [some_tcl_function somedata]
%>
<html>
<body>
<%=$somevar%>
</body>
</html>

.tcl starts life as a tcl script and then outputs html
for example:
ReturnHeaders
set somevar [some_tcl_function somedata]
ns_write "<html>
<body>
$somevar
</body>
</html>
"
Collapse
Posted by Bruno Mattarollo on

Or you could see the .adp files as the templates where you store your design and layout and the .tcl files where you store your logic. In that way you achieve the holly grail of CMS of separation of content/logic/layout.

I prefer to see it that way so that as soon as you start coding you have that idea in mind and it's really important (at least I like to think so ;)

Collapse
Posted by Don Baccus on
AOLserver doesn't directly support that, though.  It's an [Open]ACS thingy.

It's not less important for that, but Rick should understand that AOLserver by itself doesn't support this presentation/computation separation.

So .... Rick ..you should use one of the [Open]ACS templating mechanisms!  Even if you don't use the rest of the toolkit.