Antville Project

Render content part as image

As part of a demo hack I did for a prospective customer planning to convert a website to Antville, I implemented a feature to interpret a content part as an image name and render that image, if it exists. This is useful when displaying images outside of the story text. You could still enter the whole image macro tag, but just taking the image name is much more comfortable for content editors and less error prone.

The feature is implemented by passing an as="image" attribute to the content part macro and the following code added to story.content_macro():

   } else if (param.as == "image") {
      var part = this.getContentPart (param.part);
      if (part && this.site.images[part]) {
         delete (param.part);
         renderImage (this.site.images[part], param);
      }
   }

Should I check this in? If so, we might consider doing the same for polls, files etc.

comment    

 
robert, July 19, 2002 at 2:58:18 PM CEST

definetly

+1 for that (great idea!).

link  


... comment
 
tobi, July 19, 2002 at 3:07:13 PM CEST

+1 for the general idea

but could we do this more generic, please? because the next thing is to wrap a content part which contains an url around another content part, e.g. the title (i think this was already requested once by jörg kantel).

currently, this is not possible, because i cannot use the link macro and the content part macro at once:

<% link to="<% story.content part="url" %>" %><% story.content part="title" %></a>

it's also impossible to put the title part as text parameter into the content macro if it had an as="link" parameter:

<% story.content part="url" as="link" text="<% story.content part="title" %>" %>

do you have any suggestions how we could do this, then?

(the relation between the image feature and what i have written here might be not so clear: it's about having a custom story extension to be processed further, e.g. as image or as link -- and i think there must be one way to solve both options and probably even more)

link  

 
hns, July 19, 2002 at 4:51:32 PM CEST

you do this using

<a href="<% this.content part="url" %>"><% this.content part="title" %></a>

This is pretty straightforward. The only restriction is that you have to have a URL, which is a good idea anyhow because of UI consistency. But the nested macro syntax we came up with at helma.antville.org is no solution either as long as nested macros can't contain attributes (you need attributes for the content macro to make sense).

If this needs to be fixed, I'd rather do it with an extension to the content macro, e.g.

<% this.content part="title" linkpart="url" %&gt

link  

 
tobi, July 19, 2002 at 5:02:00 PM CEST

ok. good.

first i wondered why i could have missed that simple solution but then i remembered that i stumbled across the fact that this way you implicitely need a url or otherwise you get an empty href (as you indicated).

i even tried to think about including the a tag as pre- and suffix but then still the closing tag remains:

<% this.content part="url" prefix="<a href="" suffix="">" %><% this content part="title" %></a>

link  


... comment
 
hns, July 19, 2002 at 4:59:16 PM CEST

it's

in the CVS.

link  


... comment


The Antville Server Fund has been a great success. Thanks to everybody who contributed!
online for 8550 Days
last updated: 1/4/11, 10:22 AM
status
Youre not logged in ... Login
menu
November 2024
SunMonTueWedThuFriSat
12
3456789
10111213141516
17181920212223
24252627282930
July
recent
zfuture's house here is zfuture's
house
by zfuture (7/31/03, 2:59 AM)
i understand your concerns however,
i hardly can think of a solution. certainly, if the...
by tobi (7/29/03, 9:47 AM)
Found several more similar sites
listed This is getting to be quite a concern to...
by cobalt123 (7/27/03, 7:56 PM)
Second Post Alert on Referrer
bug livecatz I put this into "help" and now here:...
by cobalt123 (7/26/03, 7:14 PM)
well it's not easy to
find from here, anyway. think we should include a link,...
by tobi (7/24/03, 11:25 AM)
So finally I found
the helma Bugzilla - stupid me.
by mdornseif (7/24/03, 10:28 AM)
clock not that it's particularly
earthshattering but the antclock is running slow by about 15...
by kohlehydrat (7/23/03, 8:25 PM)
but blogosphere.us isn't can't really
be rated as spam can it?
by kohlehydrat (7/23/03, 8:08 PM)
More referrer spam www.webfrost.com
by Irene (7/23/03, 7:55 PM)
How to log skin names
I accessed to console?? Hi, I would like to know...
by winson (7/23/03, 4:12 PM)

Click here to get an XML version of this weblog.

Made with Antville
powered by
Helma Object Publisher