Home
The Toolkit for Online Communities
16679 Community Members, 1 member online, 2636 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Development : Passing s in included templates.

Forum OpenACS Development: Passing s in included templates.

Icon of envelope Request notifications

Collapse
Posted by Dave Bauer on
Occaisionally one wishes to <include> a template that is also used as a full page. Such a template may use the <property> tag. I would be useful if a <property> set in a <include>d template was set in the including template to be passed up to the master template.

Is this something we might want to do? Is it even possible?

There could be duplicate <properties> set in both templates. We might want to ignore those in the include if there are duplicates. The other option would be to somehow specify which properties to accept from the included template in the include tag ie: <include src="my_template" property="foo" property="bar">

Collapse
Posted by Benjamin Bytheway on
On the subject of <property> tags. We ran into some limitations with the implementation of the tag on a site we did last summer. The templating documentation says "The contents of the tag may be plain text, static HTML, or a dynamic template that references local data sources." This is only partially true.

It is possible to have variable replacement take place inside the property, such as:

<property name="title">@title@</property>

But it is not possible to include any other templating tags inside the property. For example:

<property name="breadcrumb">
<list name="breadcrumb">@breadcrumb:item@</list>
</property>
Would cause an error. Our need was to have a multiple tag inside the property tag, so a compiled chunk of html was passed up to the master.

In the end, we found other ways to make the design work. I did try to unravel the mystery of the templating system to fix this, but was unsuccessful. If there are other enhancements to be made to the <property> tag, then this fix would be a nice addition.

Collapse
Posted by Benjamin Bytheway on
As far as properties being passed up to including templates, I think this is a great idea.  I can think of many uses this would have had in past projects.

One difficulty that you didn't mention:  If the included template was also meant to be a stand-alone page, most of the time it would have a <master> tag as a part of it.  The templating system would have to be smart enough to remove or ignore that tag to avoid interfering with the including page's <master> tag.

Collapse
Posted by Dan Wickstrom on
It appears that all three of these features could be accomodated with a little hacking on the template tags.  The property tag doesn't currently evaluate the chunk between the tags, so that's why you couldn't include a multiple tag in between the open and close tags.

Have you tried passing a property up to an including template.  Just based on a cursory glance, it appears that it might already work.  I haven't tried to follow all of the ins and outs, but it appears that properties are stored in the same tcl array each time a template is evaluated.  I haven't worked out the order of evaluation, due to recursions of template evals, to see if it works out correctly.

Collapse
Posted by xx xx on
It should work, just pass in variables. However, one thing I noticed is that you should not query for the passed in variables in ad_page_contract of the included page. This will set the variable to default, throw an error, or it silently uses a pre-existent value. This means, that if foo is in the original page, you may want pass foo2 with the include tag and use:
if {[info exists foo2]} {set foo foo2} (or change what ever property you like)
You could also put @foo2@ straight in the adp file, but this will throw an error whenever the original templated page is not called from within the include.
Collapse
Posted by Dave Bauer on
Dan,

I tried it. It does not work. I had to do this in the tcl file.

upvar 1 keywords
set keywords "foo"

then set the property in the calling template.

Collapse
Posted by Dave Bauer on
Mainly we have used this to set stuff in the HEAD of the resulting html page. In that previous example we wanted to set META keywords. The other use is to set a style tag or a script that is required by an included widget.

So mainly we want to add or modify the header_stuff variable.

Collapse
Posted by Robert Locke on
Didn't someone create a variation of the include tag that behaved more like an inline include (ie, evaluation is at current adp level)?
Collapse
Posted by Tom Jackson on

I did, it was a pretty simple tag. However, it didn't look for an associated .tcl file, and if you changed the file to be included, you would need to touch the main file, because the script didn't check the mtime of the included file.

I called it the read tag but maybe a better name would be 'source'?

Collapse
Posted by Tomasz Kosiak on
I badly need property tag that parses its chunk. I would likt to do somthing like this:

<property name"topmenu">
<multiple name="menuitem">
<a href="@menuitem.href@">@menuitem.name</a>
</multiple>
</property>

As I investigated that problem I found that this is not that strightforward change to ATS. I would have to get deeper understanding of ACS Templating. So I would like to ask if sombody already did it or know how that should be done.

Or mayby there are other ways to pass some info from slave to master then slave tag and property variables. I know that I could set properties from *.tcl script, but in my case this should be done by graphic designer that wants to control topmenu layout.

Collapse
Posted by Jade Rubick on
Tomas, why can't you do this? I believe you can build multiples yourself.. not just from queries.

Look at the docs for Templating. There are some examples that might be pertinent.

Or stop by on IRC.

I've already build topmenu multirow myself. That is not a problem. I would like to use it in property tag to prepare html snippet to be used in master template.

I've read ATS docs quite carefully. If you can point to documentation or example URL I would be thankful. I would like to build html in *.adp not in .*tcl file which is trival.

What is the IRC channel you've mentioned? How to get there?

Collapse
Posted by Talli Somekh on
Tomasz, for the IRC channel you need an IRC client like Chatzilla, Xchat or mIRC. Once you have one of those, the server to connect to is:

irc.freenode.net

The channel to connect to is:

#openacs.

talli

Collapse
Posted by xx xx on
I suppose it could work if you store it in a string:

set multiple_menuitem "
    <multiple name=menuitem>
    <a href=$menuitem(href)>$menuitem(name)</a>
    </multiple>
"

<property name"topmenu">
@multiple_menuitem@
</property>

Does that help?

Collapse
Posted by xx xx on
No.. probably not. Did you try to use:
set multiple_menuitem [template::adp_parse ".../menuitem-adp-file"]