![](/img/trans.png)
[英]Building .NET project through VS2015 that uses my Nuget Package doesn't copy .config file
[英]Update the dashboard.config through my package
我使用在我的包中調用的sectionservice創建了我自己的應用程序/部分。 我現在正在嘗試向此部分添加html / angular儀表板視圖,但我找到的所有教程都是關於編輯dashboard.config並在此處添加指向視圖的指針。
我的目標是創建一個獨立的包,我不想直接編輯這個文件,而是實際地在我的部分添加一個儀表板。
這可能嗎? 任何人都可以鏈接我的教程或暗示我應該使用什么服務。
我不知道這有多適用,但我被要求粘貼我的代碼以創建原始部分。
using Umbraco.Core;
using Umbraco.Core.Models;
namespace Labs.App_Plugins.StueyLabs
{
public class StueyLabsSection : ApplicationEventHandler
{
protected const string stueyLabsSectionAlias = "stueyLabs";
protected override void ApplicationStarted(UmbracoApplicationBase umbraco, ApplicationContext context)
{
// Gets a reference to the section (if already added)
Section section = context.Services.SectionService.GetByAlias(stueyLabsSectionAlias);
if (section != null) return;
// Add a new "Stuey" section
context.Services.SectionService.MakeNew("Stuey Labs", stueyLabsSectionAlias, "icon-stuey");
// Grant all existing users access to the new section
context.Services.UserService.AddSectionToAllUsers(stueyLabsSectionAlias);
}
}
}
這可能有助於其他試圖做與我類似的事情。 在寫作時,Umbraco沒有代碼優先選項來添加開箱即用的儀表板。
提出了兩種解決方案:
包裹動作
這些將在其他人安裝包時運行,將xml注入dashboard.config以自定義視圖。
Skybrud.Umbraco.Dashboard
這似乎是一個可以通過NuGet安裝的插件,它允許您通過c#操作Umbraco 7中的儀表板。
我選擇了第一條路線,一旦我對結果感到滿意,我會用任何有用的資源更新這個答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.