cancel
Showing results for 
Search instead for 
Did you mean: 

How to add document preview feature into SearchResultPropertyLink

janaka1984
Star Contributor
Star Contributor

Hi,

how can i add document preview feature into SearchResultPropertyLink?

Reards

janaka

12 REPLIES 12

ddraper
World-Class Innovator
World-Class Innovator

Follow these steps...

  1. Create a custom module that extends AlfSearchResult
  2. Make your custom module override the createDisplayNameRenderer function (by default this creates the SearchResultPropertyLink instance). You will still want to create a SearchResultPropertyLink for the majority of node types - preview will only be relevant for the "document" type. You can just create a PropertyLink​ instance for nodes of "document" type and make the link publish on the ALF_SHOW_NODE_PREVIEW topic (which will be subscribed to by the NodePreviewService). You can find examples of how this works in the Thumbnail module source)
  3. You then need to create an extension to the faceted search page (see this blog post for an example of extending the faceted search page) to swap the default AlfSearchResult widget for your custom widget

thanks dave. i use  NodePreviewService and PropertyLink. it is working.

i have one issue , i need to pass mimetype with node otherwise title of dialogbox is empty.

how to pass that node? i have used following, but node is not working please correct this.

{

                                              name: "alfresco/renderers/PropertyLink",

                                              config: {

                                             

                                                 propertyToRender: "displayName",

                                                 publishTopic: "ALF_SHOW_NODE_PREVIEW",

                                                

                                            

                                                 publishPayload: {

                                                    node:{

                                                        mimetype:"{mimeTypes}"

                                                    }

                                                 }

                                              }

ddraper
World-Class Innovator
World-Class Innovator

If you look at the JSDoc for the SHOW_NODE_PREVIEW topic you'll see that it expects either a "node" or "nodeRef" parameter in the payload. By default the PropertyLink will publish the currentItem (that is the search result) when clicked (you can stop it publishing the currentItem by configuring "useCurrentItemAsPayload" to be false. You should not need to configure a publishPayload at all.

Can you clarify how it is not working. I think that the issue may be that the NodePreviewService is not actually present in the default faceted search page so you should add it to the model.jsonModel.services array in your extension.

Once you've done this, if it's still not working you should use the pub/sub log (accessed from the "Debug Menu" of Share) to confirm that the subscription is being created and that the correct publication is being made.

Hi dave,

i have used my own aikau dashlet and render document details by using alfSearchResult. Also i have used 'PropertyLink' for 'displayName' column and NodePreviewService as service. publishTopic in 'PropertyLink' is  'ALF_SHOW_NODE_PREVIEW'.  i set payload as follow and set useCurrentItemAsPayload to be false. it can pass necessary parameter (node,nodeRef,displayName) into function of service. then it can properly popup document , when click on particular document.

                                        publishPayload: {

                                                    node:{

                                                        mimetype:"{mimetype}"

                                                    },

                                                    nodeRef: "{nodeRef}",

                                                    displayName:"{displayName}"

                                                 }

ddraper
World-Class Innovator
World-Class Innovator

I'm still not sure I understand the issue... as I stated before, you shouldn't need to configure a publishPayload (as you just need the nodeRef at the root of the payload which the currentItem already has) as the NodePreviewService will just load the full metadata for the node (providing that the DocumentService is also on the page).

However, if you do wish to configure a payload it is essential that you have configured:

publishPayloadType: "PROCESS",

publishPayloadModifiers: ["processCurrentItemTokens"]

...as this is what will enable you to use token substitution in the payload.

Can you confirm that you have done this please?

i have used following propertyLink.  it is working.   if i does not use publishPayload, it is unable to fill node with meta data (return node is undefined) . therefore i can not see title of popup dialog

{

                                              name: "alfresco/renderers/PropertyLink",

                                              config: {                                                

                                                 propertyToRender: "displayName",

                                                 publishTopic: "ALF_SHOW_NODE_PREVIEW",                                                

                                                 useCurrentItemAsPayload: false,

                                                 publishPayloadType: "PROCESS",

                                                 publishPayloadModifiers: ["processCurrentItemTokens"],

                                                 publishPayload: {

                                                    node:{

                                                        mimetype:"{mimetype}"

                                                    },

                                                    nodeRef: "{nodeRef}",

                                                    displayName:"{displayName}"

                                                 }

                                              }

                                           }

ddraper
World-Class Innovator
World-Class Innovator

What is the value of the currentItem for the PropertyLink? You will probably need to add a breakpoint to this to find out... I don't understand why it does not contain the attributes required if you are rendering search results.

here i added screen shot to show which attribute is available with payload and this, When i have used following 'PropertyLink' without 'publishPayload' . then i can see filled node under this.currentItem object. but To get mimetype, payload.node should be filled , when click on link.

please confirm whether i have referenced correct attribute of PropertyLink

{

                                              name: "alfresco/renderers/PropertyLink",

                                              config: {                                                

                                                 publishGlobal: true,

                                                 propertyToRender: "displayName",

                                                 publishTopic: "ALF_SHOW_NODE_PREVIEW",                                    

                                                 useCurrentItemAsPayload: true

                                              }

                                           }

nodeservice.JPG

ddraper
World-Class Innovator
World-Class Innovator

What you're actually showing in that screenshot is the currentItem temporarily assigned to the NodePreviewService (a currentItem is assigned temporaily in the showPreview function)... this appears to contain the full metadata for a node so must have been retrieved via the DocumentService when a payload was provided that just contained a nodeRef attribute (because the search API doesn't return full node metadata). This currentItem will be a remnant of the last time a preview was shown.

What I'm actually interested in is the payload object that is just clipped out of the screenshot you've pasted - this contains the information on the current request for a preview.


What is interesting about this is that it looks like you've already got through the code path to load the metadata for a node based on a supplied node preview so you should have at least seen a preview successfully generated previously!