Hi,

For a few months now, we at Nature have been throwing around the idea of 
developing a whole bunch of Velocity Tools to enable us to develop a truly 
component-based templating solution for our sites.

I noticed Nathan's comment 
(http://www.theserverside.com/news/thread.tss?thread_id=20404#89523) about 
this from 2003 and was wondering whether anyone out there has any experiences 
of developing this kind of solution that they would like to share?

Our basic idea was this:
Outline:
We have multiple sites with many different views, but most reuse broadly 
similar 'components' to construct these views. Through use of Velocity Tools, 
we could make these components independent and reusable by making available 
methods that, using a passed argument, knew how to retrieve the data they 
required in any particular instance.

1. Sub-class VelocityViewServlet to initialize required contexts (e.g. global, 
group, site etc) and populate with configuration data from files (file 
retrieval based on convention / data being the basic stuff like names of 
sites, values used throughout all sites or all of group etc)

2. Create a suite of Velocity Tools, each with an accompanying velocity 
template ... or multiple templates - which template was used could be 
determined by the presence or absence of vm files based upon convention?

for example: a "MenuTool" might have a template that looked like this:

#set ( $Menu.name = 'main menu' ) #* a string which identifies which type of 
menu we're dealing with *#
#set ( $Menu.site = $Config.siteName ) #* so it knows where to get the correct 
menu items *#
<ul>
#foreach ( $MenuItem in $Menu.items )
    <li><a href="$MenuItem.getURL()">$MenuItem.getText()</a></li>
#end
</ul>

Through its interface with the Velocity Tool, this one 'main menu' template 
file could then be used globally and multiple times in the same view.

Another way to do the same thing without the use of Velocity Tools is to 
create extensive configuration files using standard *.vm files and #set 
directives. However, in my experience, that solution is quite laborious to 
maintain and prone to error when editing is done by inexperienced users.

Your comments and suggestions / experience would be most gratefully received.

Best wishes,

Chris

-- 
Christopher Townson
New Technology Developer
Nature Publishing Group

t. +44 (0)20 7843 4644    
e. [EMAIL PROTECTED]

********************************************************************************
   
DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
not the original intended recipient. If you have received this e-mail in error
please inform the sender and delete it from your mailbox or any other storage
mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
liability for any statements made which are clearly the sender's own and not
expressly made on behalf of Macmillan Publishers Limited or one of its agents.
Please note that neither Macmillan Publishers Limited nor any of its agents
accept any responsibility for viruses that may be contained in this e-mail or
its attachments and it is your responsibility to scan the e-mail and 
attachments (if any). No contracts may be concluded on behalf of Macmillan 
Publishers Limited or its agents by means of e-mail communication. Macmillan 
Publishers Limited Registered in England and Wales with registered number 
785998 
Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS   
********************************************************************************

Reply via email to