mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
committed by
Sébastien Ros
parent
8ca5351872
commit
b6a4ef609d
@@ -1,5 +1,26 @@
|
||||
@{ Layout.Title = T("Create New Content").ToString(); }
|
||||
@using Orchard;
|
||||
@using Orchard.ContentManagement;
|
||||
@using Orchard.Core.Contents;
|
||||
|
||||
@{
|
||||
IOrchardServices _orchardServices;
|
||||
WorkContext.TryResolve<IOrchardServices>(out _orchardServices);
|
||||
|
||||
Layout.Title = T("Create New Content");
|
||||
}
|
||||
|
||||
@foreach (var type in Model.ContentTypes) {
|
||||
<p>@Html.ActionLink((string)type.DisplayName, "Create", new { Area = "Contents", Id = (string)type.Name, ContainerId = Model.ContainerId, ReturnUrl = Request.QueryString["ReturnUrl"] })</p>
|
||||
var content = _orchardServices.ContentManager.New(type.Name);
|
||||
|
||||
if (Authorizer.Authorize(Permissions.CreateContent, content)) {
|
||||
ContentItemMetadata metadata = _orchardServices.ContentManager.GetItemMetadata(content);
|
||||
|
||||
RouteValueDictionary createRouteValues = metadata.CreateRouteValues;
|
||||
createRouteValues.Add("ContainerId", Model.ContainerId);
|
||||
createRouteValues.Add("ReturnUrl", Request.QueryString["ReturnUrl"]);
|
||||
|
||||
var url = Url.RouteUrl(createRouteValues);
|
||||
|
||||
<p><a href="@url">@type.DisplayName</a></p>
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
@using Orchard.Core.Contents;
|
||||
@using Orchard;
|
||||
@using Orchard.ContentManagement;
|
||||
@using Orchard.Core.Contents;
|
||||
@using Orchard.Core.Contents.ViewModels;
|
||||
@using Orchard.Security;
|
||||
@using Orchard.Security.Permissions;
|
||||
|
||||
@{
|
||||
IOrchardServices _orchardServices;
|
||||
WorkContext.TryResolve<IOrchardServices>(out _orchardServices);
|
||||
|
||||
var typeDisplayName = Model.TypeDisplayName;
|
||||
var pageTitle = T("Manage Content");
|
||||
var createLinkText = T("Create New Content");
|
||||
@@ -28,7 +33,17 @@
|
||||
}
|
||||
@if (showCreateContentButton) {
|
||||
<div class="manage">
|
||||
@Html.ActionLink(createLinkText.Text, "Create", new { Area = "Contents", Id = (string)Model.Options.SelectedFilter }, new { @class = "button primaryAction" })
|
||||
@{
|
||||
if (!String.IsNullOrWhiteSpace((string)Model.Options.SelectedFilter)) {
|
||||
var content = _orchardServices.ContentManager.New(Model.Options.SelectedFilter);
|
||||
ContentItemMetadata metadata = _orchardServices.ContentManager.GetItemMetadata(content);
|
||||
|
||||
var url = Url.RouteUrl(metadata.CreateRouteValues);
|
||||
<a class="button primaryAction" href="@url">@createLinkText.Text</a>
|
||||
} else {
|
||||
@Html.ActionLink(createLinkText.Text, "Create", new { Area = "Contents", Id = (string)Model.Options.SelectedFilter }, new { @class = "button primaryAction" });
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
|
||||
Reference in New Issue
Block a user