cancel
Showing results for 
Search instead for 
Did you mean: 

How to show custom content model fields on browse.jsp

rluberti
Champ in-the-making
Champ in-the-making
Hi all,

I've created a new custom content model (Alfresco CE 2.1.0) and it works, but I'd like to show some of those new fields on the standard "Content Items" section of a space.
Can I modify browse.jsp to do it? how?

thanks in advance,

   Roberto
8 REPLIES 8

sdavis
Champ in-the-making
Champ in-the-making
Hi Roberto,

You can use a custom template view as defined at http://wiki.alfresco.com/wiki/Template_Guide

rluberti
Champ in-the-making
Champ in-the-making
thanks Scott,

how can I access my custom fields from the FTL? having something like this:

<model name="my:mynewmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Example custom Model</description>
   <author></author>
   <version>1.0</version>

   <!– Imports are required to allow references to definitions in other models –>
   <imports>
          <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <!– NOTE: The following namespace my.new.model should be changed to reflect your own namespace –>
   <namespaces>
      <namespace uri="my.new.model" prefix="my"/>
   </namespaces>

   <types>

      <!– Definition of new Content Type: Standard Operating Procedure –>
      <type name="my:sop">
         <title>Documento di Progetto Renco</title>
         <parent>cm:content</parent>
         <properties>
            <property name="my:fifDate">
               <type>d:date</type>
            </property>

            <property name="my:publishedDate">
               <type>d:datetime</type>
            </property>
            <property name="my:authorisedBy">
               <type>d:text</type>
            </property>
         </properties>
         <associations>
          <association name="my:signOff">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </association>
            <child-association name="my:processSteps">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
                        </child-association>
         </associations>
      </type>

    </types>

    <aspects>

      <!– Definition of new Content Aspect: Image Classification –>
      <aspect name="my:imageClassification">
         <title>Image Classfication</title>
         <properties>
            <property name="my:width">
               <type>d:int</type>
            </property>
            <property name="my:height">
               <type>d:int</type>
            </property>
            <property name="my:resolution">
               <type>d:int</type>
            </property>
         </properties>
      </aspect>

   </aspects>

</model>

how can I access the property "my:fifDate" ?

thanks again,

  Roberto

sdavis
Champ in-the-making
Champ in-the-making
For that, the best reference can be found in your install under Company Home > Space Templates > Presentation Templates.  Just checkout what's packaged by default.

Included below is a more complex example that comes with the Records Management module:

<#– Records Report - Template to apply to a records space to report on status of records –>



<style>

body {font:small/1.2em arial,helvetica,clean,sans-serif;font:x-small;margin-top: 10px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px;min-width:500px;}

</style>



<#assign datetimeformat="dd MMM yyyy HH:mm">



<#assign currentpath="+PATH:\"${space.qnamePath}//*\"">

<#assign rma="{http://www.alfresco.org/model/record/1.0}">



<#macro debug errcat="" errmsg="">

    <#– <tr><th colspan="2">${errcat}</th><td colspan="8">${errmsg}</td></tr> –>

</#macro>



<table width="100%"  border="0" cellpadding="1" cellspacing="1">



<#if hasAspect(document, "${rma}record") = 1>

   <tr>

      <td><b>Record - ${document.properties["rma:recordIdentifier"]} <#if hasAspect(document, "${rma}cutoff") = 1>  <font style='color:red'>Cutoff</font></#if></b></td>

   </tr>

   <tr>      

      <td><hr></td>

   </tr>



   <#if hasAspect(document, "${rma}vitalrecord") = 1>

      <tr>

           <td>

              <#if document.properties["rma:nextReviewDate"]?exists>

                 Vital record due for next review at ${document.properties["rma:nextReviewDate"]?string("dd MMM yyyy HH:mm")}

              <#else>

                 Vital record with no review date set.

              </#if>

           </td>      

      </tr>

   </#if>

   

   <#if hasAspect(document, "${rma}scheduledCutoff") = 1 && hasAspect(document, "${rma}cutoff") = 0>

      <tr>      

         <td>

            <#if document.properties["rma:cutoffDateTime"]?exists>            

               Scheduled for cutoff at ${document.properties["rma:cutoffDateTime"]?string("dd MMM yyyy HH:mm")}

            <#else>

               Scheduled for cutoff with no cut off date set.

            </#if>

         </td>      

      </tr>   

   </#if>      



   <#if hasAspect(document, "${rma}held") = 1>

      <tr><td>

         <#if document.properties["rma:frozen"]>

             This record is frozen

         <#else>   

            <#if document.properties["rma:holdUntil"]?exists>

               Held until ${document.properties["rma:holdUntil"]?string("dd MMM yyyy HH:mm")}

            <#else>

               Held with no held date specified

            </#if>

         </#if>

      </td></tr>   

   </#if>   



   <#if hasAspect(document, "${rma}obsolete") = 1>

      <tr>

         <td>This record is obsolete</td>            

      </tr>   

   </#if>



   <#if hasAspect(document, "${rma}superseded") = 1>

      <tr>

         <td>This record has been superseded</td>            

      </tr>   

   </#if>



   <#if hasAspect(document, "${rma}transfered") = 1>

      <tr>

         <td>This record has been transfered</td>            

      </tr>   

   </#if>



<#else>

   <tr>

      <td>This template can only be applied to a record</td>            

   </tr>

</#if>



</table>

rluberti
Champ in-the-making
Champ in-the-making
thanks , your suggestion worked!!!

here is the code that works with my model posted before:


<table width="100%"  border="0" cellpadding="1" cellspacing="1">

<#list space.children as child>
      <#if child.isDocument>
   
       <tr>
          <td><b>${child.name}</b></td>

          <td><b>${child.properties["my:fifDate"]?date}</b></td>

       </tr>
     </#if>

   </#list>

</table>

I also found that it can be done extending BrowseBean, it will be my next experiment…..


Roberto

lmanoh
Champ in-the-making
Champ in-the-making
Hi
i followed ur steps. Create custom content model as you mentioned above and access the same in template, but i got an error like this in console
Caused by: freemarker.core.ParseException: Encountered "&" at line 1, column 533 in workspace://SpacesStore/b4f4ad64-ac57-425c-950f-823177b4e6fc.
Was expecting one of:
    <STRING_LITERAL> …
    <RAW_STRING> …
    "false" …
    "true" …
    <INTEGER> …
    <DECIMAL> …
    "." …
    "+" …
    "-" …
    "!" …
    "[" …
    "(" …
    "{" …
    <ID> …

        at freemarker.core.FMParser.generateParseException(FMParser.java:4697)
        at freemarker.core.FMParser.jj_consume_token(FMParser.java:4568)
        at freemarker.core.FMParser.UnaryExpression(FMParser.java:323)
        at freemarker.core.FMParser.MultiplicativeExpression(FMParser.java:435)
        at freemarker.core.FMParser.AdditiveExpression(FMParser.java:385)
        at freemarker.core.FMParser.RangeExpression(FMParser.java:556)
        at freemarker.core.FMParser.RelationalExpression(FMParser.java:511)
        at freemarker.core.FMParser.EqualityExpression(FMParser.java:476)

my custom content.xml file would be,
<model name="my:mynewmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Example custom Model</description>
   <author></author>
   <version>1.0</version>

   <!– Imports are required to allow references to definitions in other models –>
   <imports>
          <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <!– NOTE: The following namespace my.new.model should be changed to reflect your own namespace –>
   <namespaces>
      <namespace uri="my.new.model" prefix="my"/>
   </namespaces>

   <types>

      <!– Definition of new Content Type: Standard Operating Procedure –>
      <type name="my:BookSKU">
         <title>BooK SKU</title>
         <parent>cm:content</parent>
         <properties>
            <property name="my:fifDate">
               <type>d:date</type>
            </property>

            <property name="my:publishedDate">
               <type>d:datetime</type>
            </property>
            <property name="my:authorisedBy">
               <type>d:text</type>
            </property>
         </properties>
         <associations>
          <association name="my:signOff">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </association>
            <child-association name="my:processSteps">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
                        </child-association>
         </associations>
      </type>

    </types>

    <aspects>

      <!– Definition of new Content Aspect: Image Classification –>
      <aspect name="my:imageClassification">
         <title>Image Classfication</title>
         <properties>
            <property name="my:width">
               <type>d:int</type>
            </property>
            <property name="my:height">
               <type>d:int</type>
            </property>
            <property name="my:resolution">
               <type>d:int</type>
            </property>
         </properties>
      </aspect>

   </aspects>

</model>

accessing code in template file (.ftl)

<table width="100%"  border="0" cellpadding="1" cellspacing="1">

<#list space.children as child>
      <#if child.isDocument>
   
       <tr>
          <td><b>${child.name}</b></td>

          <td><b>${child.properties["my:fifDate"]?date}</b></td>

       </tr>
     </#if>

   </#list>

</table>

please help me in this regards.
-Lenin

rluberti
Champ in-the-making
Champ in-the-making
have you created the "context file" that references the custom content file?

here is the example:

custom_model_context.xml:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <!– Registration of new models –>   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/custom_content.xml</value>
            </list>
        </property>
    </bean>
         
</beans>



Roberto

lmanoh
Champ in-the-making
Champ in-the-making
Thanks alot for replying.

yes. i did. and here is the code,

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <!– Registration of new models –>
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/BookSKU.xml</value>
            </list>
        </property>
    </bean>
</beans>

and i changed one more file for custom content model called  web-client-config-custom.xml

<alfresco-config>
   <!– **************************** AV Config Start ************************–>
   <!– Make sure that the properties for FTBContent are available –>
   <config evaluator="node-type" condition="ccs:BookSKU">
   <property-sheet>
   <show-property name="mimetype" display-label-id="content_type" component-generator="MimeTypeSelectorGenerator"/>
   <show-property name="size" display-label-id="size" converter="org.alfresco.faces.ByteSizeConverter" show-in-edit-mode="false"/>
   <show-property name="ccs:DisplayName"/>
   <show-property name="ccs:SAPArticleID"/>
   <show-property name="ccs:Author"/>
   <show-property name="ccs:ISBN"/>
   <show-property name="ccs:ListPrice"/>
   <show-property name="ccs:SalePrice"/>
   </property-sheet>
   </config>
   
   <!– List ccs:FTBContent when creating new content –>
   <config evaluator="string-compare" condition="Content Wizards">
   <content-types>
   <type name="ccs:BookSKU"/>
   </content-types>
   </config>
   
   <!– Lists the custom aspect in business rules Action wizard –>
   <config evaluator="string-compare" condition="Action Wizards">
   <subtypes>
   <type name="ccs:BookSKU"/>
   </subtypes>
   </config>
   
</alfresco-config>

apart from this BookSKU.xml file, which is i mentioned in above post.
this all are workking fine. i can able to enter information through UI(alfresco) and edit the same.

Now the proplem is i need to access this data in the ftl file. for example in default content, we can access the user name by  using the tag..${person.properties.uderName} as well as we can access the first name, email ect..

Now i need to acces tne   this custum content feild in template or xml file.

please help me.

-lenin.

rluberti
Champ in-the-making
Champ in-the-making
it should work as  ${document.properties["ccs:Author"]} …..if it doesn't work I don't have an alternative….sorry

- Roberto