cancel
Showing results for 
Search instead for 
Did you mean: 

including static html in ftl

salma
Champ in-the-making
Champ in-the-making
Hi
Can we include static html in FTL. :?:  :?:

For ex: header.html is common across all pages. can we include header.html in other ftl's so that, when particular page is generated this header.html is automatically added.

I have seen some example in ftl's http://freemarker.sourceforge.net/docs/dgui_quickstart_template.html but it is not working in alfresco.

please let me know how to solve this.

thanks in advance
5 REPLIES 5

sujaypillai
Confirmed Champ
Confirmed Champ
Yes off course you can include html files into ftl files.

Say that you have a file abc.html and xyz.ftl into the same directory - then the following statement in xyz.ftl

<#include "abc.html">
would do the trick for you.

salma
Champ in-the-making
Champ in-the-making
No , the above solution didn't work.
When I was creating the ftl including the above code, it is showing as some error.


Did you use the above code for including any static html..

If so can you please provide me one sample

sujaypillai
Confirmed Champ
Confirmed Champ
Could you please post the error and if possible the including html file?

salma
Champ in-the-making
Champ in-the-making
Please find the details as mentioned below

FTL details.

<#ftl ns_prefixes={"D", "http://www.alfresco.org/training"}>
   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Test page</title>
</head>
<body>
  <h1>Test page</h1>
  <p>Blah blah…</p>

<#include "header.html">

</body>
</html> 

XSD :


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:trn="http://www.alfresco.org/training"
           targetNamespace="http://www.alfresco.org/training"
           elementFormDefault="qualified">

         <xs:element name="home">
            <xs:complexType>
            <xs:sequence>
                  <xs:element name="Objectives" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
            </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>

Error
Please correct the errors below then click Finish.

    * Error generating rendition using home.ftl: freemarker.template.TemplateException: Error reading included file header.html
    * 03120019 Found 3 integrity violations: Mandatory property not set: Node: avm://GoaFirst–admin–preview/-1;www;avm_webapps;ROOT;home.html Type: {http://www.alfresco.org/model/wcmappmodel/1.0}rendition Property: {http://www.alfresco.org/model/wcmappmodel/1.0}parentrenditionproperties Mandatory property not set: Node: avm://GoaFirst–admin–preview/-1;www;avm_webapps;ROOT;home.html Type: {http://www.alfresco.org/model/wcmappmodel/1.0}rendition Property: {http://www.alfresco.org/model/wcmappmodel/1.0}parentrenderingenginetemplate Mandatory property not set: Node: avm://GoaFirst–admin–preview/-1;www;avm_webapps;ROOT;home.html Type: {http://www.alfresco.org/model/wcmappmodel/1.0}rendition Property: {http://www.alfresco.org/model/wcmappmodel/1.0}primaryforminstancedata

header.html


<html>
<head>
</head>
<body>
This is in header
</body>
</html>


Please let me know the solution.

sujaypillai
Confirmed Champ
Confirmed Champ
I didn't get time to go through your files for testing. This is what worked for me:

test.xsd
=======
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:alf="http://www.alfresco.org" >
<xs:element name="article">
    <xs:complexType>
      <xs:sequence>
      <xs:element name="title" type="xs:normalizedString"/>
      <xs:element name="description" type="xs:string">
         <xs:annotation>
            <xs:appinfo>
               <alf:appearance>minimal</alf:appearance>
            </xs:appinfo>
         </xs:annotation>
      </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

test.ftl
=======
<html>
<body>
<h1>${article.title}</h1>
<#include "include.html">
</body>
</html>

test.xsl
======
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<html>
<head></head>
<body>
<xsl:variable name="title">
      <xsl:value-of select="article/title"/>
</xsl:variable>
<xsl:value-of select="$title"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

include.html
==========
Included html….

* make sure that the included html file doesn't have <html> tags in it if you have it in the main file where it is being included
** the included file (include.html) should be placed in the same folder where the webform lies (test.xsd). In my case my folder Web Forms > test has the below files:
1. test.xsd
2. test.xsl
3. test.ftl
4. include.html


Hope so this works as a reference for you. Check it out…