cancel
Showing results for 
Search instead for 
Did you mean: 

Overriding Share

nunut
Champ in-the-making
Champ in-the-making
Hi there,,,
I get trouble extending my alfresco share and i really need your help   Smiley Happy . My question is how can I override file "search.js" in folder [tomcat-instalation]\webapps\share\components\search"?
Let me clear my question. When we need to override web script we just need to put our code in "extension\templates\webscripts\" but in the my situation where we should put it


Thanks
10 REPLIES 10

jpotts
World-Class Innovator
World-Class Innovator
In this case, you aren't talking about a web script. The file, search.js, is client-side JavaScript, not server-side JavaScript. If you want to extend it, you really need to create your own client-side JavaScript file and then override the "head" web script for the component that will be dependent on your new file to add it as a dependency using the @script tag.

Then, in your version of the client-side JavaScript file, use YAHOO.extend to sub-class the client-side component to make it do what you want.

There's a simple example of this in the custom actions tutorial where I extend the client-side Alfresco.RuleConfigAction component with my own. You should be able to use that as an example to do something similar.

Jeff

chrisstoph
Champ in-the-making
Champ in-the-making
Hi Jeff

I have the same problem. Could you please tell me, where do I have to put that custom client side javascript (search.js) when using the maven all-in-one archetype?

Thanks

angelborroy
Community Manager Community Manager
Community Manager
<CODE>$project/src/main/amp/components/search/search.js</CODE>

This will override default Alfresco JS, but maybe it's a better choice to extend and override one single method.
Hyland Developer Evangelist

chrisstoph
Champ in-the-making
Champ in-the-making
Hi Angel

Thanks for the answer. I created a search_custom.js file, where I override the neccessary functions. But unfortunately it does not make any sense, if I copy the search_custom.js file in the folder, which you proposed. Share does not recognise it. Anyway, after maven build, it's generated in $project\amp\target\amp\components\search\, however I think it should be in $project\share\target\share\components\search
What do I do wrong?

angelborroy
Community Manager Community Manager
Community Manager
Have you included your new JS file on <CODE>search.get.html.ftl</CODE> as Jeff pointed?
<javascript>
<@markup id="js">
   <#– JavaScript Dependencies –>
   <@script src="${url.context}/res/components/search/search-lib.js" group="search"/>
   <@script src="${url.context}/res/components/search/search.js" group="search"/>
   <@script src="${url.context}/res/components/search/search_custom.js" group="search"/>
</@>
</javascript>
Hyland Developer Evangelist

chrisstoph
Champ in-the-making
Champ in-the-making
Yes, I did. But the search_custom.js is not present at all, if I browse the scripts with FireBug on the Search site.

angelborroy
Community Manager Community Manager
Community Manager
Can you open AMP generated (it's a ZIP file) and verify <CODE>search_custom.js</CODE> path?

It should be at <CODE>components/search/search_custom.js</CODE>
Hyland Developer Evangelist

anotheralfresco
Champ in-the-making
Champ in-the-making
Angel,

I have the need to override the renderCellDescription function of Alfresco.Search.
My question is really about how to override that function. I am not very familiar with the YAHOO api.
I was able to override just the function that I need in DocumentList, as follow:


(function()

{
   //Enable/disable (local) debug mode
   var debug_mode = false;
   /**
    * YUI Library aliases
    */
   var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event;

   /**
    * Alfresco Slingshot aliases
    */

   var $html = Alfresco.util.encodeHTML,
      $isValueSet = Alfresco.util.isValueSet;

   Alfresco.DocumentListViewRenderer.prototype.renderCellDescription = function DL_VR_renderCellDescription(scope, elCell, oRecord, oColumn, oData){
         …..
        };
})();

This works fine for DocumentLibary, however AlfrescoSearch seem to be a bit different. The "renderCellDescription" function is defined inside the "Search_setupDataTable". How do i override it? Do I have to override the "Search_setupDataTable"? Or is there a way to override just the "renderCellDescription"?

angelborroy
Community Manager Community Manager
Community Manager
You have to override the whole _setupDataTable function in AlfrescoSearch component. In my opinion, there is no easy way to override just renderCellDescription function.
Hyland Developer Evangelist