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:
skewed
2010-01-27 01:38:43 +00:00
parent 32f4850692
commit 5612e1e0c8
3 changed files with 10 additions and 3 deletions

View File

@@ -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);

View File

@@ -6,6 +6,7 @@
var args = {
"contentType": options.contentType,
"id": options.id,
"containerId": options.containerId,
__RequestVerificationToken: $("input[name=__RequestVerificationToken]").val()
};

View File

@@ -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 %><%