mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-22 21:02:08 +08:00
Fixing a bug in the client-side routable slugifier to not suggest a new slug for an existing content item. Near term solution that should be a little more smart about knowing if the content item is published and perhaps always offer up the generated slug as an option to clobber the existing (for published pages redirects would need to be put in place to not break the web :P)
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4046000
This commit is contained in:
@@ -13,13 +13,18 @@ namespace Orchard.Core.Common.Controllers {
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Slugify(string contentType, int? containerId) {
|
||||
public ActionResult Slugify(string contentType, int? id, int? containerId) {
|
||||
var slug = "";
|
||||
ContentItem contentItem = null;
|
||||
|
||||
if (string.IsNullOrEmpty(contentType))
|
||||
return Json(slug);
|
||||
|
||||
var contentItem = _contentManager.New(contentType);
|
||||
if (id != null)
|
||||
contentItem = _contentManager.Get((int) id);
|
||||
|
||||
if (contentItem == null)
|
||||
contentItem = _contentManager.New(contentType);
|
||||
|
||||
if (containerId != null) {
|
||||
var containerItem = _contentManager.Get((int)containerId);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
var args = {
|
||||
"contentType": options.contentType,
|
||||
"id": options.id,
|
||||
"containerId": options.containerId,
|
||||
__RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
|
||||
};
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
$(this).slugify({
|
||||
target:$("<%=String.Format("input#{0}Slug", !string.IsNullOrEmpty(Model.Prefix) ? Model.Prefix + "_" : "") %>"),
|
||||
url:"<%=Url.Slugify() %>",
|
||||
contentType:"<%=Model.RoutableAspect.ContentItem.ContentType %>",<%
|
||||
contentType:"<%=Model.RoutableAspect.ContentItem.ContentType %>",
|
||||
id:"<%=Model.RoutableAspect.ContentItem.Id %>",<%
|
||||
var container = Model.RoutableAspect.ContentItem.As<ICommonAspect>().Container;
|
||||
if (container != null) { %>
|
||||
containerId:<%=container.ContentItem.Id %><%
|
||||
|
||||
Reference in New Issue
Block a user