Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Duncan McDougall 35 posts 62 karma points
    Nov 10, 2009 @ 11:11
    Duncan McDougall
    0

    Adding Custom Section Toolbar Button in Dashboard

    I've added a custom section to the dashboard using dashboard.config just fine. What I can't find how to do is add a button to the toolbar just below the tabs similar to save, save publish. What is the xml for this and how are actions executed?

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Nov 10, 2009 @ 11:29
    Chris Houston
    0

    Hi Dunk,

    I think you need to manually add this to the "umbracoApp" table:

    The fields in the table are:

    sortOrder
    appAlias
    appIcon
    appName
    appInitWithTreeAlias

    The icons are then defined in the umbracoGui.css file:

    /* tray sprites */
    .traycontent{background-position: -18px -18px;}
    .traymedia{ background-position: -18px -90px;}
    .trayusers{ background-position: -18px -162px;}
    .traysettings{ background-position: -18px -234px;}
    .traydeveloper{ background-position: -18px -306px;}
    .traymember{background-position: -18px -378px;}
    .traystats{background-position: -18px -450px;}
    .traytranslation{background-position: -18px -522px;}
    /* end tray sprites */

    Cheers,

    Chris

     

  • Richard Soeteman 4054 posts 12927 karma points MVP 2x
    Nov 10, 2009 @ 17:22
    Richard Soeteman
    2

    Do you mean a normal umbraco menu?

    I've managed to to that. I did a demo about this on the Benelux Meetup here's my code.

    ASCX File:

    <%

    @ Register Assembly="controls" Namespace="umbraco.uicontrols" TagPrefix="cc1" %>

    <

     

    cc1:Pane ID="FirstNamePane" runat="server">

     

    <cc1:PropertyPanel ID="FirstNamePanel" runat="server" Text="Firstname" >

     

    <asp:TextBox ID="FirstNameTextBox" runat="server" CssClass="umbEditorTextField"/>

     

    </cc1:PropertyPanel>

    </

     

    cc1:Pane>

    <

     

    cc1:Pane ID="Pane2" runat="server">

     

    <cc1:PropertyPanel ID="LastNamePanel" runat="server" Text="Lastname" >

     

    <asp:TextBox ID="LastNameTextBox" runat="server" CssClass="umbEditorTextField"/>

     

    </cc1:PropertyPanel>

    </

     

    cc1:Pane>

    Code Behind

    namespace

     

    EditorDemo

    {

     

    public partial class EditorControls : System.Web.UI.UserControl

    {

     

    MenuImageButton _buttonSave;

     

    protected void Page_Load(object sender, EventArgs e)

    {

     

    //If you want to add a menu to a dashboard control you have to cast the parent to TabPage

     

    if (Parent is TabPage)

    {

     

    TabPage tabPage = Parent as TabPage;

    _buttonSave = tabPage.Menu.NewImageButton();

    _buttonSave.Click +=

    new ImageClickEventHandler(_buttonSave_Click);

    _buttonSave.AlternateText =

    "Save";

    _buttonSave.ImageUrl =

    GlobalSettings.Path + "/images/editor/save.gif";

    tabPage.HasMenu =

    true;

    }

    }

     

    /// <summary>

     

    /// Save

     

    /// </summary>

     

    void _buttonSave_Click(object sender, ImageClickEventArgs e)

    {

     

    //Test if the Base class is BasePage

     

    if (Page is BasePage)

    {

     

    //Okay we are in Umbraco

     

    string message = string.Format("{0} {1} saved", FirstNameTextBox.Text, LastNameTextBox.Text);

     

    //Use the SpeechBubble method on page to show the message

    ((

    BasePage)Page).speechBubble(BasePage.speechBubbleIcon.success, "Message to the user", message);

    }

    }

    }

    }

    The trick is to cats the Parent as a Tabpage. The Tabpage holds a reference to the menu, so you can use that to add MenuImageButtons(in this case a button save) And you can add event handlers to that button_save action. That is done in the _buttonSave_Click handler which shows you the speechbubble message, but you can also use this as a hook to provide your own save mechanism.

    Hope this helps you,

    Richard 

     

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Nov 10, 2009 @ 18:24
    Chris Houston
    0

    Ah opps!

    Just realised I miss read your original question!

    Appologies for my miss-leading answer, hopefully it was still helpful for someone :)

    Cheers,

    Chris

  • Christopher W. Brandsdal 72 posts 133 karma points
    Mar 15, 2011 @ 10:18
    Christopher W. Brandsdal
    0

    Thanks, Richard! Saved me alot of work. ;-)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies