2016-07-28 2 views
3

미디어 라이브러리에 탐색 기능과 동작에 셰이프를 첨부 할 수있는 기능이 있습니다. 그러나 나는 액션에 액션 셰이프를 추가하여 내 모듈에서 액션을 호출하기 위해 미디어 라이브러리에 새로운 버튼을 추가 할 수 있도록 노력하고있다. 미디어 라이브러리 AdminController.cs에서 Orchard CMS 미디어 라이브러리에 사용자 지정 작업 추가

는 :
// let other modules enhance the ui by providing custom navigation and actions 
var explorer = Services.ContentManager.New("MediaLibraryExplorer"); 
explorer.Weld(new MediaLibraryExplorerPart()); 

var explorerShape = Services.ContentManager.BuildDisplay(explorer); 

var viewModel = new MediaManagerIndexViewModel { 
    CustomActionsShapes = explorerShape.Actions, // <-- I need to have my shape that is rendered as a button in here 
}; 

아직도 오차드 너무 녹색 비트,하지만 모양을 사용하고 그들을 배치에 대한 이해에 구멍 같은 느낌. 나는 아무 것도 저장되지 않기 때문에 버튼을 렌더링하는 모양을 위해 파트가 필요하다고 생각하지 않습니까?

답변

3

나는 이것을 처리 할 수 ​​있었다. 먼저 작업 영역에 배치

public class MediaLibraryExplorerPartDriver : ContentPartDriver<MediaLibraryExplorerPart> { 
    protected override DriverResult Display(MediaLibraryExplorerPart part, string displayType, dynamic shapeHelper) { 
     return ContentShape("Parts_MediaLibraryExplorer_MyActionShape",() => shapeHelper.Parts_MediaLibraryExplorer_MyActionShape()); 
    } 
} 

그런 다음 MediaLibraryExplorerPartDriver에 MediaLibraryExplorerPart에 대한

<Placement> 
    <Place Parts_MediaLibraryExplorer_MyActionShape="Actions:6" /> 
</Placement> 

그런 다음 생성 템플릿 새로운 형태를 반환과 모양에 대한 (/ 뷰 부품/MediaLibraryExplorer.MyActionShape.cshtml) 버튼을 눌러 모듈 컨트롤러 동작을 호출하십시오.

@Html.ActionLink(T("Click Me").Text, "Index", "Admin", new { area = "Orchard.MyModule" }, new { id = "click-me-link", @class = "button" }) 

얼마나 쉬웠습니까?!