cancel
Showing results for 
Search instead for 
Did you mean: 

Customizing the aikau search placeholder

iwkse
Star Contributor
Star Contributor

I have this problem with customizing the aikau search placeholder. I've created a share amp with maven and setting the extension like this to extend the SearchBox widget:

<extension>
   <modules>
      <module>
          <id>Aikau SearchBox Customization</id>
          <version>1.0</version>
          <auto-deploy>true</auto-deploy>
          <configurations>
              <config evaluator="string-compare" condition="WebFramework" replace="false">
                 <web-framework>
                     <dojo-pages>
                      <packages>
                            <package name="header" location="js/header"/>
                       </packages>
                     </dojo-pages>
                   </web-framework>
                 </config>
               </configurations>
            </module>
        </modules>
</extension>

with the structure in META-INF:

▾ js/
   ▾ header/
       ▾ i18n/
          SearchBox.properties
       SearchBox.js

having SearchBox.js:

define(["dojo/_base/declare", "alfresco/header/SearchBox"],
    function(declare, SearchBox) {
           return declare([SearchBox], {
               i18nRequirements: [ {i18nFile: "./i18n/SearchBox.properties"} ],
           });
});

and the properties file:

search.instruction=he who seeks shall find, Seek and ye shall find 

Any idea why the properties is not overridden?

[edit]

Never mind..I just find it out. Last time I was searching this aikau didn't allow to override the placeholder but this is been added! Thanks Dave Draper‌ !

No need now to extend the widget but it's enough to set a customization extension and modify like:

var searchBox = widgetUtils.findObject(model.jsonModel.widgets, "id", "HEADER_SEARCH");
searchBox.config.placeholder= "search-custom.label";

1 ACCEPTED ANSWER

ddraper
World-Class Innovator
World-Class Innovator

Glad you were able to resolve the problem! Let me know if there are any other issues I can help with.

View answer in original post

15 REPLIES 15

ddraper
World-Class Innovator
World-Class Innovator

Glad you were able to resolve the problem! Let me know if there are any other issues I can help with.

iwkse
Star Contributor
Star Contributor

Thanks!

Just for a matter of curiosity. This way to extend a widget is still valid (even if I didn't manage to let it works)? For example, before the aikau change you suggested me to extend the widget and just point the 18nRequirements: [ {i18nFile: "./i18n/my_custom.properties"} ]


Is this approach still valid?

ddraper
World-Class Innovator
World-Class Innovator

Yes, that's a still a perfectly valid way to extend and provide additional properties (or override properties).

iwkse
Star Contributor
Star Contributor

I'm asking because when I tried as the first post it didn't work for me. Not sure why

ddraper
World-Class Innovator
World-Class Innovator

I think I'd need to see your code to be able to answer that. It is an approach used throughout Aikau though. Were you trying to override properties or add in new ones?

iwkse
Star Contributor
Star Contributor

I was overriding the SearchBox widget with custom properties. I can create a complete example later and post it here so that you can take a look.

Thank you

iwkse
Star Contributor
Star Contributor

I've just uploaded this share amp project:

https://ufile.io/34121 

nwali
Star Contributor
Star Contributor

I am using Alfresco Community 5.0.d and I have added below line in share-header.get.js then I get error on login.

var searchBox = widgetUtils.findObject(model.jsonModel.widgets, "id", "HEADER_SEARCH");

where else if I add below then nothing happens:

var searchBox = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SEARCH");

Also I have used widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_REPOSITORY"); then works fine to remove the repository.

whats difference between model.jsonModel and model.jsonModel.widgets ??

so far in share-header.get.js file:

widgetUtils.deleteObjectFromArray(model.jsonModel, "id", "HEADER_REPOSITORY");

var headerSearch = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SEARCHBOX");

if (headerSearch) {

headerSearch.config.showPeopleResults = false;
headerSearch.config.placeholder="Search files";
}

How can I remove the people suggestion ?

iwkse
Star Contributor
Star Contributor

Hi,

I think you can't change this property like this because it's not being exposed as the placeholder is. I think you need to go though the module override for change this property. But I had problems with the module override, it didn't work for me. I uploaded an example project to let ‌ looks at it but it seems the link is expired. Please if you're able to do it with the override method I am interested to know, because I couldn't do it. I ask you for a pleasure, since I don't have this example project anymore, if you could upload here an example aikau custom override module you will be really helpful.

Thank you