Umbraco:创建没有单独项目/DLL的自定义树?
我需要向“网站”(即服务器的inetpub目录中的文件夹)的自定义部分添加一个自定义树 我可以通过创建一个新项目(因此是一个新的DLL)并将DLL复制到网站的bin文件夹中来实现。但这将产生对网站之外的另一个项目的依赖,这在我的情况下是不可接受的 有没有一种方法可以在不创建单独DLL的情况下创建自定义树(例如,只在AppCode文件夹中创建一个类) 是否有办法在umbracoAppTree表的treeHandlerAssembly列中输入类名(而不是DLL名) 提前谢谢 我解决了Umbraco:创建没有单独项目/DLL的自定义树?,umbraco,Umbraco,我需要向“网站”(即服务器的inetpub目录中的文件夹)的自定义部分添加一个自定义树 我可以通过创建一个新项目(因此是一个新的DLL)并将DLL复制到网站的bin文件夹中来实现。但这将产生对网站之外的另一个项目的依赖,这在我的情况下是不可接受的 有没有一种方法可以在不创建单独DLL的情况下创建自定义树(例如,只在AppCode文件夹中创建一个类) 是否有办法在umbracoAppTree表的treeHandlerAssembly列中输入类名(而不是DLL名) 提前谢谢 我解决了 这篇文章帮助了
这篇文章帮助了我 除此之外,我找不到任何其他地方的帮助,希望这将有助于别人
static object _locker = new object();
/// <summary>
/// Adds a custom tree to a custom section in Umbraco
/// </summary>
/// <param name="customTreeType">Your custom tree that is inherited from BaseTree</param>
/// <param name="alias">Your custom section alias</param>
public static void RenderCustomTree(Type customTreeType, string alias)
{
// Check if customTree is already registered
if (TreeDefinitionCollection.Instance.Count(x => x.TreeType == customTreeType) == 0)
{
lock (_locker)
{
// Double check
if (TreeDefinitionCollection.Instance.Count(x => x.TreeType == customTreeType) == 0)
{
Application customApp = new Application(alias, alias, ".traycontent");
// Create the tree definition
var myCustomTree = new TreeDefinition(customTreeType,
new umbraco.BusinessLogic.ApplicationTree(true, true, 0,
alias, //applicationAlias,
alias, //alias
alias, //title
".sprTreeFolder", //iconClosed
".sprTreeFolder_o", //iconOpened
"uComponents.Core", //assemblyName
customTreeType.ToString(), //type
null), //action
customApp);
// Add our tree definition to the collection at runtime
TreeDefinitionCollection.Instance.Add(myCustomTree);
}
}
}
}
public void Init(HttpApplication application)
{
RenderCustomTree(typeof(YourCustomTree), "yourCustomSection");
}