2017-09-14 45 views
0

我有一個自定義部分,自定義樹。Umbraco 7 - 自定義菜單項和樹,導航如何工作?

我有一點麻煩了解如何設置正確的行爲時:

您點擊一個節點在你的樹進行編輯。 您點擊節點上的菜單項,如「創建」 在我的解決方案中,我使用相同的視圖來編輯和創建記錄。

在我的樹中,這是如何生成一個節點。

var routeToView = "rewards/rewardsTree/editcampaign/campaign-" + campaign.Id.ToString(); 

var campaignNode = CreateTreeNode("campaign-" + campaign.Id.ToString(), id.Split('-')[1], queryStrings, campaign.CampaignName, "icon-folder color-yellow", true, routeToView); 

本步驟是我想要的路線:(我的HTML文件的名稱是editcampaign.html),它也傳遞「活動-6」

/umbraco#/rewards/rewardsTree/editcampaign/campaign-6 

當用戶點擊創建節點上的「菜單項」 - 我想送他們到相同的URL,但只是用例如指出錯誤編號:

umbraco#/rewards/rewardsTree/editcampaign/brand-1 

,我不希望它彈出出側的

這是我到目前爲止已經試過:

//This finds the view, but it comes up in a dialog also how do I pass the Id (brand-1) 
    MenuItem mi = new MenuItem("editcampaign", "Create Campaign"); 
        menuItemCollection.Items.Add(mi); 

//Also Tried this finds puts a whole another umbraco UI inside a dialog 

mi.LaunchDialogView("#rewards/rewardsTree/editcampaign/brand-1", "TITLE GOES HERE"); 

任何人都可以點我的菜單的樹木周圍,一般後臺的充分資料和導航?

回答

0

我相信有一個選項可以在「創建」菜單項上設置視圖路徑,這會使其正常打開?另外,讓你的路徑像/ view/path/here/id更好嗎?然後,當您創建一個新項目時,只需發送0作爲ID。 Github上的Umbrangular是一個有很多自定義部分和視圖示例的項目。

編輯:下面是一個例子

protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings) 
{ 
    var menu = new MenuItemCollection(); 

    MenuItem createCategory = new MenuItem("createcategory", "Create Category"); 

    createCategory.AdditionalData.Add("ParentCategoryId", id); 

    createCategory.NavigateToRoute("/path/to/view/category/0"); 

    createCategory.Icon = "add"; 

    menu.Items.Add(createCategory); 

    return menu; 
}