cancel
Showing results for 
Search instead for 
Did you mean: 

Add new buttom on header

zazugue
Champ in-the-making
Champ in-the-making
Hellow guys. I am trying to add a new buttom on the header. So i followed this tutorial https://www.alfresco.com/blogs/developer/2013/09/16/customizing-the-share-header-part-3/

And i make a new java project and made this hierarchy :

Project
|
|–> alfresco
|    |
|    |–> site-data
|    |      |
|    |      |–> custombuttom.xml
|    |
|    |–> site-webscripts
|          |
|          |–> share-header.get.js
|
|–> build.xml



Inside custombuttom.xml
————————


<extension>
  <modules>
    <module>
      <id>Add Buttom Exersys</id>
      <version>1.0</version>
      <customizations>
        <customization>
          <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
          <sourcePackageRoot>custom-header</sourcePackageRoot>
        </customization>
      </customizations>
    </module>
  </modules>
</extension>



————————

Inside share-header.get.js
————————


//<import resource="classpath:/alfresco/site-webscripts/org/alfresco/share/imports/share-header.lib.js">
var headerMenus = widgetUtils.findObject(model.jsonModel, "id", "HEADER_APP_MENU_BAR"); //Retrouve l'objet Menu Bar
var NewAppItems = [
{
         id: "HEADER_EXERSYS",
         name: "alfresco/menus/AlfMenuBarItem",
         config:
      {
            label: "header.menu.exersys.label",
            targetUrl: "alfresco/service/exersys/"
         }
}
];
headerMenus.appItems = NewAppItems; //L'attribut appItems permet d'ajouter l'objet à gauche



The problem is when i deploy in alfresco, i found it in "http://localhost:8080/share/page/modules/deploy" and activate it but nothing change and i don't have error in logs.

Did i forgot something?
Thank in advance ><"
5 REPLIES 5

redraccoon
Star Contributor
Star Contributor
I think it's because of headerMenus.appItems = NewAppItems;

try to push it in your header

<java>var headerMenu = widgetUtils.findObject(model.jsonModel, "id", "HEADER_TASKS_GROUP");
if (headerMenu != null) {
    headerMenu.config.widgets.push(  {
        id: "HEADER_MY_AIKAU_FILTER",
        name: "alfresco/header/AlfMenuItem",
        config:
        {
           id: "HEADER_MY_AIKAU_FILTER",
           label: "workflowsFilteredListAikauShare.label",
           iconClass: "alf-mytasks-icon",
           targetUrl: "hdp/ws/crnpdc/cpp/workflowsFilteredListAikauShare"
        }
     });
}
</java>

and if you want, instead of manual deploy
<javascript><auto-deploy>true</auto-deploy>  </javascript>  just after the <version>

zazugue
Champ in-the-making
Champ in-the-making
Thank for your answer.
So it's my new code :

//<import resource="classpath:/alfresco/site-webscripts/org/alfresco/share/imports/share-header.lib.js">
var headerMenu = widgetUtils.findObject(model.jsonModel, "id", "HEADER_TASKS_GROUP"); //Retrouve l'objet Menu Bar
if(headerMenu!=null)
{
   headerMenu.config.widgets.push({
      
      id: "HEADER_EXERSYS",
      name: "alfresco/header/AlfMenuItem",
      config:
      {
         id: "HEADER_EXERSYS",
            label: "header.menu.exersys.label",
            targetUrl: "alfresco/service/exersys/"
        }
    });
}


But now, i can't find in the list of deploy. It's very weird. :0 (and it doesn't working :/)

redraccoon
Star Contributor
Star Contributor
Ok I also tried on my eclipse I think I understood, it's the way you put your files

- your extension file "custombuttom.xml" is in site-data, but he has to be in "extensions" folder

- then your "share-header.get.js" have to be in the "custom-header"  folder (as you said in your extension file), you have to create it in the site-webscript



try my code .get.js with this extension file

site-webscripts/fr/crnpdc/header/share-header.get.js

site-data/extensions/crnpdc-cpp-share-header-extension.xml


<extension>
  <modules>
    <module>
      <id>Add custom menu item - workflows filtered list - to header</id>
      <version>1.0</version>
      <auto-deploy>true</auto-deploy> 
      <customizations>
        <customization>
          <targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
          <sourcePackageRoot>fr.crnpdc.header</sourcePackageRoot>
        </customization>
      </customizations>
    </module>
  </modules>
</extension>


and click in the 5th button in the header, "tasks" in english, when it's fine for you just change the code as you wanted

zazugue
Champ in-the-making
Champ in-the-making
Yeah i noticed that but i think it's cause of a module i just installed (PDF_TOOLKIT). I had a lot of problems since i installed it.

I uninstall it and i will tell you Smiley Surprised

zazugue
Champ in-the-making
Champ in-the-making
Okay for some reasons, my webscript is not find by the deploy module. I added inside the file share-header.get.js and it works. DIrty way but it works, thanks for the help Smiley Surprised