2016-07-28 2 views
3

メディアライブラリには、ナビゲーションとアクションにシェイプを付ける機能があります。しかし私はアクションにアクションシェイプを追加して、モジュール内のアクションを呼び出すためにメディアライブラリに新しいボタンを追加できるようにする方法を試しています。Orchard CMSメディアライブラリにカスタムアクションを追加してください

メディアライブラリAdminController.csから:

// 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

私はこれを解決することができました。まず付き形状のためのテンプレート(ビュー/パーツ/ MediaLibraryExplorer.MyActionShape.cshtml)を作成後、アクションゾーンで

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

を置くMediaLibraryExplorerPartDriver

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

にMediaLibraryExplorerPartのための新たな形を返しますボタンを押してモジュールコントローラアクションを呼び出します。

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

どのように簡単でしたか?

関連する問題