SaphuA
SaphuA

Reputation: 3150

Umbraco add dashboard with code

Ok, with some help I found the code to add a new application / section without modifying the config manually. Add an assmebly with this class in the /bin folder and the section is automatically added to Umbraco.

[Application("guestbook", "Guestbook", ".trayguestbook", 20)]
public class Class1 : IApplication
{

Then you can modify the Tree by adding a class that inherits from BaseTree.

[Tree("guestbook", "guestbookTree", "Guestbook")]
public class Class2 : BaseTree
{

Is there a way to modify the dashboard with a similair approach as well?

Thanks!

Upvotes: 1

Views: 1621

Answers (1)

Douglas Ludlow
Douglas Ludlow

Reputation: 10942

As far as I know, there isn't a code first approach to modifying the dashboard.config. However, if you wrap your project into an Umbraco package, you can use package actions to add a dashboard section. Here's an example from the documentation:

<Action runat="install" alias="addDashboardSection" dashboardAlias="MyDashboardSection">
  <section>
    <areas>
      <area>default</area>
      <area>content</area>
    </areas>
    <tab caption="Last Edits">
      <control>/usercontrols/latestEdits.ascx</control>
      <control>/usercontrols/PostCreate.ascx</control>
    </tab>
    <tab caption="Create blog post">
      <control>/usercontrols/new.ascx</control>
    </tab>
  </section>
</Action>

For more details on package actions see Package Action Samples. For more information of creating Umbraco packages see How to create a project package for Umbraco?.

Upvotes: 2

Related Questions