cancel
Showing results for 
Search instead for 
Did you mean: 

Forms

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi all!!

    In Alfresco Community 2.9b there's a space called "Forms"… I can create a "form" and then choose it in "Crate Content"… It produces an XML file.
Can i transform that file in a "html" or "text" file so the users can read it?!
I have XLM schema for the form and I'm trying to create an FreeMarker Template but i can't manage that to work…

My XML Schema (.xsd):
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:si="http://www.alfresco.org/alfresco/simple"
           targetNamespace="http://www.alfresco.org/alfresco/simple"
           elementFormDefault="qualified">
  <xs:element name="simple">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="string" type="xs:normalizedString"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

My FreeMarker Template (.ftl)
I add it to space Data Dictionary -> Presentation Templates. Using "Create Content".
<#ftl ns_prefixes={"D":"http://www.alfresco.org/alfresco/simple"}>
<html>
   <body>
   ${simple.string}
   </body>
</html>

(and)
I get this error:
Error during processing of the template 'Expression simple is undefined on line 4, column 6 in workspace://SpacesStore/7e3ca012-4ad3-11dd-b304-4383877d69ce.'. Please contact your system administrator.

Is this possible?! … What I'm doing wrong?!?
Please help!!!!
Thanks!

João Duarte
3 REPLIES 3

pmonks
Star Contributor
Star Contributor
DM Forms (the feature you're referring to) don't support renditioning templates directly - that's currently only available for Web (WCM) Forms.  That said you could configure a rule that fires when new XML files are added to a space and that runs a custom transformer using the XML file as input.  This custom transformer could transform the XML however you like, including via Freemarker or XSL templates.

Cheers,
Peter

zaizi
Champ in-the-making
Champ in-the-making
Alternatively you can use the Custom View functionality (http://wiki.alfresco.com/wiki/Template_Guide#Custom_Template_Views) of spaces to use a template to display the contents within that space and sub-spaces.

This is actually a very powerful feature. A really good example of how you can create a totally custom UI using Custom View and templates is the Calendar functionality included in 2.9B Community. It uses the Custom View to set up a tabbed view of YUI Calendar widgets. AJAX calls to Alfresco web scripts get and display events; also allow you to edit and create events. These events are actually simple text files within a sub space. You can of course use XML.

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi!! Thanks both!! .. pmonks and zaizi… Smiley Happy

I'm geting something with this FreeMarker Template:

<#if document.mimetype = "text/xml">
   <#assign dom=document.xmlNodeModel>
   ${dom.simple.string}
</#if>

It shows exactly what I want but only if I choose "Preview in Template"… and then choose the template submitted above. I wonder if theres a way to "click" in the file and the template runs automatically.

My goal is to make a Space called "Contacts". The user fill the form "Contact" creating the XML file. Then someone could enter in that Space and see a list of contacts (list of "Content Items"). If the user wants to see the contact details (saved in the XLM file) it just have to click in the corresponding file.
Is this the correct way to do this?! … or there is another way?!?…
Thanks again!!

João Duarte