Dashboard > Community Wiki > ... > Developing with Magnolia > How to add a custom button in AdminCentral
How to add a custom button in AdminCentral Log In View a printable version of the current page.

Added by GrĂ©gory Joseph , last edited by Boris Kraft on Jun 23, 2008  (view change)
Labels: 

How to add a custom button to the left hand side icon bar in Admin Central

For Magnolia 3 with a custom module

Place your icon (24x24px transparent GIF or PNG) in this folder of your maven magnolia module project:

/src/main/resources/mgnl-resources/icons/24/

Then add a new menu item to the magnolia menu. See

Configuration: /modules/adminInterface/config/menu

In that configuration reference your icon with a path which starts with "/.resources", followed by the path to your icon in the maven project structure after "mgnl-resources", so if you have an icon named "mystuff.png" in the maven project structure like this:

/src/main/resources/mgnl-resources/icons/24/mystuff.png

the value of the "icon" node data in your menu config must be:

/.resources/icons/24/mystuff.png

Finally install your module and it should be displayed in the menu.

What to check if icon is not displayed
  • Inspect your menu item to see where Magnolia is looking for your icon.
  • Un-jar your module JAR to make sure that the icon is inside in a "/mgnl-resources/..." folder

The following applies to Magnolia 2.1 revision 400 something.

Have you ever wondered what the "Custom button" on the left hand side of Admin Central was and how you can add your own button there? Well, here's a first slim explanation - feel free to add your own discoveries to it. Maybe some day it will turn into a useful piece of information.

There are two ways to get a button to appear in the left hand side button column in Admin Central

a) Add it in admintemplates/adminCentral/adminCentral.jsp directly

  • look for the other standard buttons "b1" to "b4" and add your button in the same way:
Button b5=new Button();
b5.setLabel(labelPre+LocaleSupport.getLocalizedMessage(pageContext, "menu.lable_key")+labelPost);
b5.setOnclick("mgnlAdminCentralSwitchExtractTree('"+ContentRepository.REPOSITORY_KEY+"');");
b5.setPushButtonTag("div");
b5.setIconSrc(request.getContextPath() + new Icon().getSrc("button_file_name",Icon.SIZE_MEDIUM));
if (repository.equals(ContentRepository.CONFIG)) b3.setState(Button.BUTTONSTATE_PUSHED);
bs.setButtons(b3);

lable_key is the key of the localized label used in the properties files in /resources/info/magnolia/adminiterface/

REPOSITORY_KEY is the name of the repository in case you would like to display the repository contents when the user hits the custom button, although don't know the exact way how to configure this yet.

button_file_name most likely is simply the name of the icon-Gif, strange enough without the file extension and without any path information. The icons used are located in /admindocroot/icons/24/. Again, I don't know the exact tricks behind this function.

b) Add the button via the configuration in /modules/adminInterface/Config/adminCentral/buttonList

  • add a new content node
  • add three node data elements to it:
    • label: The text as it is displayed to the right of the button icon
    • iconSrc: Full path and file name relative to webapps, e.g. /admindocroot/icons/24/news.gif
    • onclick: What should happen when the user clicks the button -> see below

Adding functionality to the button
As far as I could figure out up to this point, you can add to functions to the button:

  • {{mgnlAdminCentralSwitchExtractNonTree('URL'); }} calls a URL relative to the contextPath
  • {{mgnlAdminCentralSwitchExtractTree('"ContentRepository.REPOSITORY_KEY"'); }} opens a repository in tree view
    Be aware that this has changed a bit from earlier 2.1 builds. And again, I don't know much yet about the exact functionalities.

So, at least we now know how to get custom buttons up on the screen. Next step would be to figure out what to do with them.

In its previous incarnation on JspWiki, this page was last edited on Feb 9, 2007 10:12:28 AM by FerrisNicolaisen
Other known authors include :

  • Will
Powered by a free Atlassian Confluence Open Source Project License granted to Magnolia International. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators