OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of: <td><a href="<dtml-var absolute_url>"><dtml-var title></a></td> It *seemed* like I should be able to code: <td><a href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td> But that creates a compilation error in the TAL HTML Parser. Maybe it's a quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
On Thu, Jun 06, 2002 at 12:48:10PM -0700, Dan Shafer wrote:
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser. Maybe it's a quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
Are you sure the compilation error involves absolute_url? What looks odd to me in the above snippet is that I've never seen a <tal> tag, only "tal:" attributes to existing tags. Try: <td><a href="/dummyurl" tal:attributes="href item/absolute_url" tal:content="item/title">Dummy Title</a></td> www.zope.org/Members/peterbe/DTML2ZPT has quite a few dtml->zpt translation examples. That and the ZPT chapters of the Zope book should be useful. The mantra is "nothing I do in ZPT should look odd to a WYSIWYG editing program; everything dynamic should look like dummy content." -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
Dan Shafer <pydan@danshafer.com> wrote:
It *seemed* like I should be able to code:
<td><a href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser.
That's because <tal:content="item/title"> is not valid XML. What would be correct is <tal:content="item/title" />. But Mike's solution is better. Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
I wrote:
That's because <tal:content="item/title"> is not valid XML. What would be correct is <tal:content="item/title" />.
Huh, brainfart. What would be correct is, for instance: <p tal:content="item/title" /> or <p tal:replace="item/title" /> But Mike's solution is still better :-) Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
In this case you must use tal:attributes <a tal:attributes="href item/absolute_url" tal:content="item/title"></a> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: <zope@zope.org> Sent: Thursday, June 06, 2002 9:48 PM Subject: [Zope] Embedding absolute_url in TAL Syntax
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser. Maybe it's a quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Thanks, Robert. But that produces a runtime Zope error: Error Type: Undefined Error Value: "absolute_url" not found in "item/absolute_url" For completeness, here's the entire relevant snippet: <tbody tal:repeat="item here/ListAllArticlesDict"> <tr> <td> <a tal:attributes="href item/absolute_url" tal:content="item/title"></a></td> <td tal:content="item/Summary">Summary</td> </tr> </tbody> We know that the first line produces the items because if I don't try to do the URL, the table displays as expected. At 11:45 PM 6/6/2002 +0200, Robert Rottermann wrote:
In this case you must use tal:attributes <a tal:attributes="href item/absolute_url" tal:content="item/title"></a> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: <zope@zope.org> Sent: Thursday, June 06, 2002 9:48 PM Subject: [Zope] Embedding absolute_url in TAL Syntax
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser. Maybe it's a quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
That probably means, that your item does not have an absolute_url method.
From the name of ListAllArticlesDict I assume it is a dictonary. Then of course the items do not have an absolute_url. Hovever you could get at the "real" object and then use its absolute_url like so:
<a tal:define="obj python:getattr(here, item['id'])" tal:attributes="href obj/absolute_url" tal:content="item/title"> </a> I assume your dictionary has an entry 'id' with the objects id. Here is a codesnippet I copied verbatim from one of my scripts that uses absolute_url: <span tal:define="vlist request/vlist | options/vlist | python:[''] * here.getNoOfArtikels()" tal:omit-tag="" tal:repeat="artikel python:here.objectValues('Photo')"> <tr> <td width="100" rowspan="2" valign="top"> <img alt="bild" style="margin-right:10" tal:condition="python:artikel.size() > 0" tal:attributes="src python:'%s?display=thumbnail' % artikel.absolute_url()"> </td> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: "Robert Rottermann" <robert@redcor.ch> Cc: "Dan Shafer" <pydan@danshafer.com>; <zope@zope.org> Sent: Friday, June 07, 2002 2:34 AM Subject: Re: [Zope] Embedding absolute_url in TAL Syntax
Thanks, Robert. But that produces a runtime Zope error:
Error Type: Undefined Error Value: "absolute_url" not found in "item/absolute_url"
For completeness, here's the entire relevant snippet:
<tbody tal:repeat="item here/ListAllArticlesDict"> <tr> <td> <a tal:attributes="href item/absolute_url" tal:content="item/title"></a></td> <td tal:content="item/Summary">Summary</td> </tr> </tbody>
We know that the first line produces the items because if I don't try to do the URL, the table displays as expected.
At 11:45 PM 6/6/2002 +0200, Robert Rottermann wrote:
In this case you must use tal:attributes <a tal:attributes="href item/absolute_url" tal:content="item/title"></a> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: <zope@zope.org> Sent: Thursday, June 06, 2002 9:48 PM Subject: [Zope] Embedding absolute_url in TAL Syntax
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a
href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser. Maybe
it's a
quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Thanks, Robert. I'll study these snippets and see if I can make the technique work. Boy, it sure seems that this ZPT/TAL stuff, far from simplifying the perceived complexity of DTML, is making things *much* more difficult and obtuse. The same code using DTML is quite straight-forward. At 07:35 AM 6/7/2002 +0200, Robert Rottermann wrote:
That probably means, that your item does not have an absolute_url method.
From the name of ListAllArticlesDict I assume it is a dictonary. Then of course the items do not have an absolute_url. Hovever you could get at the "real" object and then use its absolute_url like so:
<a tal:define="obj python:getattr(here, item['id'])" tal:attributes="href obj/absolute_url" tal:content="item/title"> </a> I assume your dictionary has an entry 'id' with the objects id.
Here is a codesnippet I copied verbatim from one of my scripts that uses absolute_url: <span tal:define="vlist request/vlist | options/vlist | python:[''] * here.getNoOfArtikels()" tal:omit-tag="" tal:repeat="artikel python:here.objectValues('Photo')"> <tr> <td width="100" rowspan="2" valign="top"> <img alt="bild" style="margin-right:10" tal:condition="python:artikel.size() > 0" tal:attributes="src python:'%s?display=thumbnail' % artikel.absolute_url()"> </td> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: "Robert Rottermann" <robert@redcor.ch> Cc: "Dan Shafer" <pydan@danshafer.com>; <zope@zope.org> Sent: Friday, June 07, 2002 2:34 AM Subject: Re: [Zope] Embedding absolute_url in TAL Syntax
Thanks, Robert. But that produces a runtime Zope error:
Error Type: Undefined Error Value: "absolute_url" not found in "item/absolute_url"
For completeness, here's the entire relevant snippet:
<tbody tal:repeat="item here/ListAllArticlesDict"> <tr> <td> <a tal:attributes="href item/absolute_url" tal:content="item/title"></a></td> <td tal:content="item/Summary">Summary</td> </tr> </tbody>
We know that the first line produces the items because if I don't try to do the URL, the table displays as expected.
At 11:45 PM 6/6/2002 +0200, Robert Rottermann wrote:
In this case you must use tal:attributes <a tal:attributes="href item/absolute_url" tal:content="item/title"></a> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: <zope@zope.org> Sent: Thursday, June 06, 2002 9:48 PM Subject: [Zope] Embedding absolute_url in TAL Syntax
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a
href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser. Maybe
it's a
quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Dan Shafer, Chief Scribe and Tablet Keeper PythonCard Open Source Project http://pythoncard.sourceforge.net
Somehow I do not believe you. In your case it aoumts to about the same code. Mabe I do not understand your problem really. Why donty you send me a dtml-code snippet where your problem is saved the dtml-way. Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: "Robert Rottermann" <robert@redcor.ch> Cc: <zope@zope.org> Sent: Friday, June 07, 2002 8:44 AM Subject: Re: [Zope] Embedding absolute_url in TAL Syntax
Thanks, Robert. I'll study these snippets and see if I can make the technique work.
Boy, it sure seems that this ZPT/TAL stuff, far from simplifying the perceived complexity of DTML, is making things *much* more difficult and obtuse. The same code using DTML is quite straight-forward.
At 07:35 AM 6/7/2002 +0200, Robert Rottermann wrote:
That probably means, that your item does not have an absolute_url method.
From the name of ListAllArticlesDict I assume it is a dictonary. Then of course the items do not have an absolute_url. Hovever you could get at the "real" object and then use its absolute_url like so:
<a tal:define="obj python:getattr(here, item['id'])" tal:attributes="href obj/absolute_url" tal:content="item/title"> </a> I assume your dictionary has an entry 'id' with the objects id.
Here is a codesnippet I copied verbatim from one of my scripts that uses absolute_url: <span tal:define="vlist request/vlist | options/vlist | python:[''] * here.getNoOfArtikels()" tal:omit-tag="" tal:repeat="artikel python:here.objectValues('Photo')"> <tr> <td width="100" rowspan="2" valign="top"> <img alt="bild" style="margin-right:10" tal:condition="python:artikel.size() > 0" tal:attributes="src python:'%s?display=thumbnail' % artikel.absolute_url()"> </td> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: "Robert Rottermann" <robert@redcor.ch> Cc: "Dan Shafer" <pydan@danshafer.com>; <zope@zope.org> Sent: Friday, June 07, 2002 2:34 AM Subject: Re: [Zope] Embedding absolute_url in TAL Syntax
Thanks, Robert. But that produces a runtime Zope error:
Error Type: Undefined Error Value: "absolute_url" not found in "item/absolute_url"
For completeness, here's the entire relevant snippet:
<tbody tal:repeat="item here/ListAllArticlesDict"> <tr> <td> <a tal:attributes="href item/absolute_url" tal:content="item/title"></a></td> <td tal:content="item/Summary">Summary</td> </tr> </tbody>
We know that the first line produces the items because if I don't try to do the URL, the table displays as expected.
At 11:45 PM 6/6/2002 +0200, Robert Rottermann wrote:
In this case you must use tal:attributes <a tal:attributes="href item/absolute_url" tal:content="item/title"></a> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: <zope@zope.org> Sent: Thursday, June 06, 2002 9:48 PM Subject: [Zope] Embedding absolute_url in TAL Syntax
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a
href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser. Maybe
it's a
quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Dan Shafer, Chief Scribe and Tablet Keeper PythonCard Open Source Project http://pythoncard.sourceforge.net
At 08:54 AM 6/7/2002 +0200, Robert Rottermann wrote:
Somehow I do not believe you. In your case it aoumts to about the same code. Mabe I do not understand your problem really. Why donty you send me a dtml-code snippet where your problem is saved the dtml-way.
OK. Here's the pure-DTML approach: <table> <tr> <th>Title</th><th>Summary</th> </tr> <dtml-in objectValues> <tr> <td><dtml-var title></td> <td><dtml-var Summary></td> </tr> </dtml-in> </table> Now here's the DTML approach where I'm using a Python script to retrieve the records and then feeding them to the page: <table> <tr> <th>Title</th><th>Summary</th> </tr> <dtml-in expr="ListAllArticles()"> <tr> <td><a href="<dtml-var absolute_url>"><dtml-var title></a> </td> <td><dtml-var Summary></td> </tr> </dtml-in> </table> Note that I added the URL stuff here, but including it in the earlier example would also be trivial. What I ended up with in TAL is pretty clean as well. It is simply that while absolute_url is a dtml-var that gets picked up without any extra effort on my part, when I go to TAL and want to use a Python script, as I understand it, I have to stuff the results into a Python list or dictionary to make them work with TAL. So I "lose contact" with the object, as it were, which means I have to grab any information I want about the object *before* I pass to the TAL processing. My comment about it being more obtuse was based not on what I eventually got working but on the code snippets you were sending, which I had a hard time following, probably because of my relative inexperience.
Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: "Robert Rottermann" <robert@redcor.ch> Cc: <zope@zope.org> Sent: Friday, June 07, 2002 8:44 AM Subject: Re: [Zope] Embedding absolute_url in TAL Syntax
Thanks, Robert. I'll study these snippets and see if I can make the technique work.
Boy, it sure seems that this ZPT/TAL stuff, far from simplifying the perceived complexity of DTML, is making things *much* more difficult and obtuse. The same code using DTML is quite straight-forward.
At 07:35 AM 6/7/2002 +0200, Robert Rottermann wrote:
That probably means, that your item does not have an absolute_url method.
From the name of ListAllArticlesDict I assume it is a dictonary. Then of course the items do not have an absolute_url. Hovever you could get at the "real" object and then use its absolute_url like so:
<a tal:define="obj python:getattr(here, item['id'])" tal:attributes="href obj/absolute_url" tal:content="item/title"> </a> I assume your dictionary has an entry 'id' with the objects id.
Here is a codesnippet I copied verbatim from one of my scripts that uses absolute_url: <span tal:define="vlist request/vlist | options/vlist | python:[''] * here.getNoOfArtikels()" tal:omit-tag="" tal:repeat="artikel python:here.objectValues('Photo')"> <tr> <td width="100" rowspan="2" valign="top"> <img alt="bild" style="margin-right:10" tal:condition="python:artikel.size() > 0" tal:attributes="src python:'%s?display=thumbnail' % artikel.absolute_url()"> </td> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: "Robert Rottermann" <robert@redcor.ch> Cc: "Dan Shafer" <pydan@danshafer.com>; <zope@zope.org> Sent: Friday, June 07, 2002 2:34 AM Subject: Re: [Zope] Embedding absolute_url in TAL Syntax
Thanks, Robert. But that produces a runtime Zope error:
Error Type: Undefined Error Value: "absolute_url" not found in "item/absolute_url"
For completeness, here's the entire relevant snippet:
<tbody tal:repeat="item here/ListAllArticlesDict"> <tr> <td> <a tal:attributes="href item/absolute_url" tal:content="item/title"></a></td> <td tal:content="item/Summary">Summary</td> </tr> </tbody>
We know that the first line produces the items because if I don't try to do the URL, the table displays as expected.
At 11:45 PM 6/6/2002 +0200, Robert Rottermann wrote:
In this case you must use tal:attributes <a tal:attributes="href item/absolute_url" tal:content="item/title"></a> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: <zope@zope.org> Sent: Thursday, June 06, 2002 9:48 PM Subject: [Zope] Embedding absolute_url in TAL Syntax
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a
href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser. Maybe
it's a
quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Dan Shafer, Chief Scribe and Tablet Keeper PythonCard Open Source Project http://pythoncard.sourceforge.net
Dan Shafer, Chief Scribe and Tablet Keeper PythonCard Open Source Project http://pythoncard.sourceforge.net
Robert, thank you. Your answer gave me the clue that led me to the solution. When I build the dictionary of each item in the folder, I can get its absolute_url then using the Python method absolute_url(). I stuff that into a third entry in the dictionary and now when I write my TAL, it is quite straightforward: <table border="1"> <th>Title</th> <th>Summary</th> <tbody tal:repeat="item here/ListAllArticlesDict"> <tr> <td> <a tal:attributes="href item/url" tal:content="item/title"></a></td> <td tal:content="item/Summary">Summary</td> </tr> </tbody> </table> Works perfectly. At 07:35 AM 6/7/2002 +0200, Robert Rottermann wrote:
That probably means, that your item does not have an absolute_url method.
From the name of ListAllArticlesDict I assume it is a dictonary. Then of course the items do not have an absolute_url. Hovever you could get at the "real" object and then use its absolute_url like so:
<a tal:define="obj python:getattr(here, item['id'])" tal:attributes="href obj/absolute_url" tal:content="item/title"> </a> I assume your dictionary has an entry 'id' with the objects id.
Here is a codesnippet I copied verbatim from one of my scripts that uses absolute_url: <span tal:define="vlist request/vlist | options/vlist | python:[''] * here.getNoOfArtikels()" tal:omit-tag="" tal:repeat="artikel python:here.objectValues('Photo')"> <tr> <td width="100" rowspan="2" valign="top"> <img alt="bild" style="margin-right:10" tal:condition="python:artikel.size() > 0" tal:attributes="src python:'%s?display=thumbnail' % artikel.absolute_url()"> </td> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: "Robert Rottermann" <robert@redcor.ch> Cc: "Dan Shafer" <pydan@danshafer.com>; <zope@zope.org> Sent: Friday, June 07, 2002 2:34 AM Subject: Re: [Zope] Embedding absolute_url in TAL Syntax
Thanks, Robert. But that produces a runtime Zope error:
Error Type: Undefined Error Value: "absolute_url" not found in "item/absolute_url"
For completeness, here's the entire relevant snippet:
<tbody tal:repeat="item here/ListAllArticlesDict"> <tr> <td> <a tal:attributes="href item/absolute_url" tal:content="item/title"></a></td> <td tal:content="item/Summary">Summary</td> </tr> </tbody>
We know that the first line produces the items because if I don't try to do the URL, the table displays as expected.
At 11:45 PM 6/6/2002 +0200, Robert Rottermann wrote:
In this case you must use tal:attributes <a tal:attributes="href item/absolute_url" tal:content="item/title"></a> Robert ----- Original Message ----- From: "Dan Shafer" <pydan@danshafer.com> To: <zope@zope.org> Sent: Thursday, June 06, 2002 9:48 PM Subject: [Zope] Embedding absolute_url in TAL Syntax
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a
href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
But that creates a compilation error in the TAL HTML Parser. Maybe
it's a
quoting thing (which I had sort of hoped would be cleaner in ZPT than it is with DTML stuff) but I can't find anything in the docs about using absolute_url in TAL, so I'm kinda stuck.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Dan Shafer, Chief Scribe and Tablet Keeper PythonCard Open Source Project http://pythoncard.sourceforge.net
Dan Shafer wrote:
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
Ick! This is _all_ wrong ;-) You want: <td><a href="dummy" tal:attributes="href item/absolute_url" tal:content="item/title">Dummy Title</a></td> In addition: <tal:content="item/title"> ...is very wrong ;-) If you want to do it like that, you need: <tal:x replace="item/title" /> cheers, Chris
Chris Withers wrote:
You want:
<td><a href="dummy" tal:attributes="href item/absolute_url" tal:content="item/title">Dummy Title</a></td>
I can't help to wonder why there isn't a common "function" for an idiom as comon as this ... neither in dtml nor Zpt. It's a rather longwinded way of writing something that should be as simple as "obj.abs_url_2_html()" regards Max M
Max M wrote:
Chris Withers wrote:
You want:
<td><a href="dummy" tal:attributes="href item/absolute_url" tal:content="item/title">Dummy Title</a></td>
I can't help to wonder why there isn't a common "function" for an idiom as comon as this ... neither in dtml nor Zpt.
It's a rather longwinded way of writing something that should be as simple as "obj.abs_url_2_html()"
write a python script ;-) <td><a tal:replace="here/abs_url_2_html">Dummy Title</a></td> cheers, Chris
Chris.... Thanks for the feedback and the input. I always learn a lot from you. At 12:21 PM 6/7/2002 +0100, Chris Withers wrote:
Dan Shafer wrote:
OK, now that I have my table of objects produced by a Python script working in ZPT, I need to figure out how to connect an entry in the table to its URL. What is the TAL equivalent of:
<td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
It *seemed* like I should be able to code:
<td><a href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
Ick! This is _all_ wrong ;-)
Yeah, that's why it didn't work! :-(
You want:
<td><a href="dummy" tal:attributes="href item/absolute_url" tal:content="item/title">Dummy Title</a></td>
Good stuff. This approach works nicely for the all-TAL approach. See my other message for how I solved this when I'm passing the item in via a Python script that generates a dictionary. All I had to do was grab the absolute_url() in the Python script and stuff it into the dictionary and it worked like a charm.
In addition:
<tal:content="item/title">
...is very wrong ;-)
If you want to do it like that, you need:
<tal:x replace="item/title" />
OK, Chris, I'll take your word that my approach was "very wrong" (even with the winkie). But that is precisely what is taught in Evan Simpson's basic ZPT tutorial. Note that I didn't have an opening angle bracket so that the tal: became the tag. (My understanding is that won't work, that tal: always has to be an attribute of a known HTML tag, right?) So if you have the time and inclination, could you explain further why tal:content="item/title" is inferior to "tal:x replace="item/title" />? Is it just that the latter approach *does* use a tal: tag rather than an attribute of another tag? Or is there something more important lurking there? The tutorial uses replace and content seemingly interchangeably, or at least doesn't explain the difference very clearly or prominently.
cheers,
Chris
Dan Shafer, Chief Scribe and Tablet Keeper PythonCard Open Source Project http://pythoncard.sourceforge.net
On Fri, Jun 07, 2002 at 10:08:28AM -0700, Dan Shafer wrote:
In addition:
<tal:content="item/title">
...is very wrong ;-)
OK, Chris, I'll take your word that my approach was "very wrong" (even with the winkie). But that is precisely what is taught in Evan Simpson's basic ZPT tutorial.
(Assuming we're talking about http://dev.zope.org/Wikis/DevSite/Projects/ZPT/SimpleTutorial) I don't see anywhere Evan has a raw <tal> tag, though I could have missed it in my skimming. The whole point of ZPT is to make perfectly-conforming XHTML dynamic; it should look *perfectly normal* as a mockup in some WYSIWYG editor, or viewed inside the management interface. This is all pretty well laid out (to my mind, at least) in the first couple of paragraphs in the "Applying the Principles" section of Evan's tutorial part 1. -- Mike Renfro / R&D Engineer, Center for Manufacturing Research, 931 372-3601 / Tennessee Technological University -- renfro@tntech.edu
Hi Dan, Dan Shafer wrote:
In addition:
<tal:content="item/title">
...is very wrong ;-)
If you want to do it like that, you need:
<tal:x replace="item/title" />
OK, Chris, I'll take your word that my approach was "very wrong" (even with the winkie). But that is precisely what is taught in Evan Simpson's basic ZPT tutorial.
The very wrong bit is the <tal:content bit. That needs to be either: <x tal:content or <tal:x content but never <tal:content
tal: became the tag. (My understanding is that won't work, that tal: always has to be an attribute of a known HTML tag, right?)
That tag doesn't have to be known or HTML but it does have to be there ;-)
there? The tutorial uses replace and content seemingly interchangeably, or at least doesn't explain the difference very clearly or prominently.
Well, the difference is pretty obvious ;-) 'content' replaces just the content of the tag it's an attribute of: <p tal:content="string:die">hello</p> ...renders to: <p>die</p> 'replace' replaces everything including the tag it's an attribute of: <p tal:replace="string:die">hello</p> ...renders to: die cheers, Chris
participants (6)
-
Chris Withers -
Dan Shafer -
Florent Guillaume -
Max M -
Mike Renfro -
Robert Rottermann