Hello all - I feel like I'm beating my head in searching for the right syntax. I'm sure no one else has been there .... Anyway, here's the challenge: In a DTML method, a string is constructed in a variable that is the relative URL of an Image. For example ... <dtml-let MyImageId="'folder/subfolder/myimage.jpg'"> using <dtml-var MyImageId> results in just the string being returned a hand constructed image tag like <img src=<dtml-var MyImageID> alt=""> will render the desired image, but does not provide access to its 'Image object' attributes like height and width. various rendering syntax such as <dtml-var render(MyImageId)> or <dtml-var _.getitem(MyImageId)> and any other variations I can come up with all merely render the string's content instead of the object I am trying to point to. Please advise: a) the syntax to render the object using a variable that contains its relative URL and b) the 'dtml-var' syntax to access an attribute that it has as an Image object, such as it's width. c) On an unrelated subject, what is the syntax to parse the contents of QUERY_STRING using the + sign as a delimiter instead of an operator. For example, the QUERY_STRING has the value arguement1+arguement2+arguement3. how would you construct a dtml-var statement that would render only 'arguement2'. An extensive Google search and review of the book did not find the answers. Any guidance will be greatly appreciated. Best regards, Gary
Gary Speer wrote:
In a DTML method, a string is constructed in a variable that is the relative URL of an Image. For example ... <dtml-let MyImageId="'folder/subfolder/myimage.jpg'">
using <dtml-var MyImageId> results in just the string being returned a hand constructed image tag like <img src=<dtml-var MyImageID> alt=""> will render the desired image, but does not provide access to its 'Image object' attributes like height and width.
Hi, you can get every object via an url with restrictedTraverse. Then you can access the properties of the object... Example: <dtml-with "restrictedTraverse('folder/subfolder/myimage.jpg')"> <dtml-var title_or_id>: <dtml-var height>, <dtml-var width> </dtml-with> Cheers, Maik
Is it possible to define new data types and to add a management tab without using ZClasses or building a new product. When not, how do you rate ZClasses in regards of stability and no long term quirks. My question is linked to the problem that I'd like to build a website out of templates which should be for flexibility very small blocks. This means the actual site(i.e. contact_html) is a folder and in this folder are other folders that contains the templates contents. But now I've got the problem to make a clean distinction between folders and folders. This means the folders that are webpages and those that are only templates. Thanks.
Sven Hohage wrote at 2003-1-28 23:31 +0100:
Is it possible to define new data types and to add a management tab without using ZClasses or building a new product. Some people like so called "monkey patches" to add new tabs.
Of course, you need write access to the file system to do this.
When not, how do you rate ZClasses in regards of stability and no long term quirks. I am using ZClasses back since Zope 2.1.6. I did not have problems (beside some minor bugs).
The mailing list archives tell you about 1 serious problem: You should not derive from a ZClass in a different product. All other (severe) problems could be resolved.
My question is linked to the problem that I'd like to build a website out of templates which should be for flexibility very small blocks. This means the actual site(i.e. contact_html) is a folder and in this folder are other folders that contains the templates contents. But now I've got the problem to make a clean distinction between folders and folders. This means the folders that are webpages and those that are only templates. Maybe, the CMF related discussion about composite documents is of interest for you...
I do not understand what your folder which is a temple is. But, I would make a Python Product, derived from "Folder" with whatever special it want to have. I cannot easily imagine in what way a folder would be a template, as a folder is essentially a set of objects and a template is something completely different. Dieter
Thank you for the suggestion. Unfortunately I cannot get past an 'Attribute Error' on ___GetItem___. If the arguement of restricted traverse is a quoted string as in your example, it works. What I need to pass is a variable that contains that string and have it rendered. For example, your suggested: <dtml-with "restrictedTraverse('folder/subfolder/myimage.jpg')"> <dtml-var title_or_id>: <dtml-var height>, <dtml-var width> </dtml-with> works, but With request setting QUERY_STRING = "myimage.jpg" <dtml-let "MyImage='folder/subfolder/'+QUERY_STRING") <dtml-with "restrictedTraverse(MyImage)"> <dtml-var title_or_id>: <dtml-var height>, <dtml-var width> </dtml-with> </dtml-let> generates the attribute error on GetItem Any ideas? Thanks, Gary ----- Original Message ----- From: "Maik Jablonski" <maik.jablonski@uni-bielefeld.de> Newsgroups: gmane.comp.web.zope.general To: "Gary Speer" <gspeer@cortech.org> Sent: Sunday, January 26, 2003 6:58 AM Subject: Re: Please help with Rendering Images in DTML Gary Speer wrote:
In a DTML method, a string is constructed in a variable that is the relative URL of an Image. For example ... <dtml-let MyImageId="'folder/subfolder/myimage.jpg'">
using <dtml-var MyImageId> results in just the string being returned a hand constructed image tag like <img src=<dtml-var MyImageID> alt=""> will render the desired image, but does not provide access to its 'Image object' attributes like height and width.
Hi, you can get every object via an url with restrictedTraverse. Then you can access the properties of the object... Example: <dtml-with "restrictedTraverse('folder/subfolder/myimage.jpg')"> <dtml-var title_or_id>: <dtml-var height>, <dtml-var width> </dtml-with> Cheers, Maik
At 05:39 PM 1/28/2003, Gary Speer wrote:
With request setting QUERY_STRING = "myimage.jpg"
<dtml-let "MyImage='folder/subfolder/'+QUERY_STRING") <dtml-with "restrictedTraverse(MyImage)"> <dtml-var title_or_id>: <dtml-var height>, <dtml-var width> </dtml-with> </dtml-let>
generates the attribute error on GetItem
Try this: <dtml-let MyImage="'folder/subfolder/'+QUERY_STRING"> HTH, Dylan
Dylan Reinhardt wrote at 2003-1-28 17:58 -0800:
At 05:39 PM 1/28/2003, Gary Speer wrote:
With request setting QUERY_STRING = "myimage.jpg"
<dtml-let "MyImage='folder/subfolder/'+QUERY_STRING") <dtml-with "restrictedTraverse(MyImage)"> You can not pass a "QUERY_STRING" component to "restrictedTraverse", only a path component.
I do not know, what you need the QUERY_STRING for, but I expect that is will contain parameters to be passed into a method call. This would look something like <dtml-let method="restrictedTraverse(path)" result="method(arg1,arg2,...)"
<dtml-with "result"> .... Dieter
participants (5)
-
Dieter Maurer -
Dylan Reinhardt -
Gary Speer -
Maik Jablonski -
Sven Hohage