cancel
Showing results for 
Search instead for 
Did you mean: 

custom property preview instead of cm:content

ranj
Champ on-the-rise
Champ on-the-rise
Hi,
I have created a custom model with custom types and properties. In the share config i have removed all the cm properties and given show id for my own custom properties.(ex: headlines,briefnews)
Now, i create a new plain text content
the create content form opens up
it has name,title,description,content (the default content type properties)
after filling up the form..(ex: i have entered "welcome note" in the name and "welcome all to alfresco" in the content)
the content gets created
the preview shows the content "welcome all to alfresco")
by the side of the preview, i see the so many options, click change type.
choose my custom type.
the type is changed successfully.
i click on inline edit, see the form containing my custom properties :headlines and briefnews.
I type in the custom fields..
and save.
it goes back to the preview, but its still showing the "welcome all to alfresco" (the cm property) , not any of my custom properties(headlines,briefnews)…


why is that not possible? or do i need to modify any config file?


Thanks in advance,
Ranj
8 REPLIES 8

bengrah
Champ on-the-rise
Champ on-the-rise
Hi Ranj,

Have you configured Share to display your custom properties?

You can do this by using share-config-custom.xml. Here's an example:

   <config evaluator="node-type" condition="mgc:knowledgeBase">
      <forms>
         <form>
            <field-visibility>
               <show id="cm:name" />
               <show id="mimetype" for-mode="view" />
               <show id="size" for-mode="view" />
               <show id="cm:author" for-mode="view"  />
               <show id="cm:creator" for-mode="view" />
               <show id="cm:created" for-mode="view" />
               <show id="cm:modifier" for-mode="view" />
               <show id="cm:modified" for-mode="view" />
               
               <show id="mgc:RegionBase" />
               <show id="mgc:ProjectName" />
               <show id="mgc:Location" />
            </field-visibility>
            <appearance>
               <set id="knowledgeBaseGroup" appearance="fieldset" label="Knowledge Base" />
         
               <field id="mgc:RegionBase" set="knowledgeBaseGroup" />
               <field id="mgc:ProjectName" set="knowledgeBaseGroup"  />
               <field id="mgc:Location" set="knowledgeBaseGroup"  />
            </appearance>
         </form>
         
         <form id="doclib-simple-metadata">
            <field-visibility>
               <show id="cm:name" />
               <!–<show id="cm:mimetype" />
               <show id="cm:size" />
               <show id="cm:author" />
               <show id="cm:creator" />
               <show id="cm:created" />
               <show id="cm:modifier" />
               <show id="cm:modified" />–>
            
               <show id="mgc:RegionBase" />
               <show id="mgc:ProjectName" />
               <show id="mgc:Location" />
            </field-visibility>
         </form>
      </forms>
   </config>

That's for configuring custom metadata to be display via the View Details page in Share for types. For aspects, replace the value for evaluator so that it is aspect instead (all lower case).

ranj
Champ on-the-rise
Champ on-the-rise
Hi Bengrah,

Thanks for the reply..i have already did what u said and it shows my custom properties right..all i need is to change the preview..want to see the preview of my custom property and not of cm:content..

Thanks in advance,
Ranj

bengrah
Champ on-the-rise
Champ on-the-rise
Hi Bengrah,

Thanks for the reply..i have already did what u said and it shows my custom properties right..all i need is to change the preview..want to see the preview of my custom property and not of cm:content..

Thanks in advance,
Ranj

Hi Raj,

What do you mean by "preview"? Are you referring to the document previewer which renders your document in Flash on any document's View Details page?

Thanks,
Ben.

ranj
Champ on-the-rise
Champ on-the-rise
Hi Bengrah,
Thats exactly what i need..Smiley Happy the document previewer shows whatever we type in "content" (in the create document form)..i jus want the previewr to show what i type in my custom property..

Thanks in advance,
Ranj

bengrah
Champ on-the-rise
Champ on-the-rise
If you take a look at your document in the Node Browser, you'll see that the property cm:content is actually of type d:content. And the value of this is actually the physical location of the document on the content store.

I don't think you're going to be able to meet your requirements out of the box ranj, but it might be possible if you use that d:content data type somehow?

Thanks,
ben

wabson
Star Contributor
Star Contributor
Hi Ranj,

The web-preview component is hard-coded to use the (default) cm:content property, but if you take a look at the file components/preview/web-preview.js inside the Share webapp, you should see the following function which is used to fetch the URL of an item's content stream, for use by the previewer.


      /**
       * Helper method for plugins to create url tp the node's content.
       *
       * @method getContentUrl
       * @param {Boolean} (Optional) Default false. Set to true if the url shall be constructed so it forces the
       *        browser to download the document, rather than displaying it inside the browser.
       * @return {String} The "main" element holding the actual previewer.
       * @public
       */
      getContentUrl: function WP_getContentUrl(download)
      {
         var nodeRefAsLink = this.options.nodeRef.replace(":/", ""),
            noCache = "noCache=" + new Date().getTime();
         download = download ? "a=true" : "a=false";
         return Alfresco.constants.PROXY_URI + "api/node/content/" + nodeRefAsLink + "/" + this.options.name + "?c=force&" + noCache + "&" + download
      },

You should see that the URLs being returned do not explicitly include the property name, so the default cm:content property is used. It would be possible to modify this function to include a property name, without too much difficulty, and that would return your custom content when the stream is requested.

HOWEVER, most of the time it's not the raw content stream that is used by a previewer, rather a custom 'thumbnail' (usually a rendition in another format) is used. It depends on which previewer you are using, but for documents it will be a SWF rendition and for images a resized image. Thumbnail content is stored as a child item of your original content item and each format thumbnail will have a unique name.

From poking around in the Spring config in rendition-services-context.xml in the repository webapp, it seems that you can change the name of the content property that is used to generate these renditions by overriding the baseRenderingAction bean, but this will be a system-wide change and you would need to ensure this will not have any unintended side effects. This is the original bean definition, note the defaultRenditionContentProp property.


   <!– Rendering Action executor beans –>

   <bean id="baseRenderingAction" abstract="true" parent="action-executer"
      class="org.alfresco.repo.rendition.executer.AbstractRenderingEngine">
      <property name="defaultRenditionContentProp"
         value="{http://www.alfresco.org/model/content/1.0}content" />
      <property name="defaultRenditionNodeType"
         value="{http://www.alfresco.org/model/content/1.0}content" />
      <property name="mimetypeMap" ref="mimetypeService" />
      <property name="contentService">
         <ref bean="ContentService" />
      </property>
      <property name="applicableTypes">
         <list>
            <value>{http://www.alfresco.org/model/content/1.0}content</value>
         </list>
      </property>
       <property name="nodeService" ref="NodeService" />
       <property name="renditionService" ref="RenditionService" />
       <property name="behaviourFilter" ref="policyBehaviourFilter" />
       <property name="renditionLocationResolver" ref="renditionLocationResolver" />
   </bean>

So, depending on the type of content that you want to preview using your custom property, the changes required could be a little more involved than it first seems. The question I would ask is why you need to do this, rather than just putting your content into the cm:content property, or perhaps defining your own custom thumbnail that would hold your custom content.

Cheers,
Will

ranj
Champ on-the-rise
Champ on-the-rise
Hi Will, Bengrah.

Thanks for ur reply. Will, thats a whole lot of info..great help..!

Regards,
Ranj.

sradha
Champ on-the-rise
Champ on-the-rise
Hi ranj,

Please post your code  of rendition-services-context.xml for your custom model properties?I have similar issue.Also i am not able to diaplay my content using "view in browser" button as it is giving unbale to find noderef exception.

Thanks,
sradha