Updating the Routeable slugify to use the item's path

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-13 08:37:13 -08:00
parent 036033116f
commit e56c682586
5 changed files with 7 additions and 25 deletions

View File

@@ -4,6 +4,7 @@ using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Routable.Models;
using Orchard.Core.Routable.Services;
using Orchard.Data;
using Orchard.DisplayManagement;
using Orchard.Localization;
@@ -62,7 +63,7 @@ namespace Orchard.Core.Routable.Controllers {
contentItem = _contentManager.Get((int)id, VersionOptions.Latest);
if (contentItem == null) {
contentItem = _contentManager.New(contentType);
contentItem = _contentManager.Create(contentType, VersionOptions.Draft);
if (containerId != null) {
var containerItem = _contentManager.Get((int)containerId);
@@ -71,9 +72,10 @@ namespace Orchard.Core.Routable.Controllers {
}
_contentManager.UpdateEditor(contentItem, this);
_contentManager.Publish(contentItem);
_transactionManager.Cancel();
return Json(contentItem.As<IRoutableAspect>().Slug ?? slug);
return Json(contentItem.As<IRoutableAspect>().GetEffectiveSlug() ?? slug);
}

View File

@@ -79,10 +79,6 @@ namespace Orchard.Core.Routable.Drivers {
updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". No spaces are allowed (please use dashes or underscores instead)."));
}
if (!_routableService.ProcessSlug(part))
_services.Notifier.Warning(T("Slugs in conflict. \"{0}\" is already set for a previously created {2} so now it has the slug \"{1}\"",
part.Slug, part.GetEffectiveSlug(), part.ContentItem.ContentType));
if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null)
_services.WorkContext.CurrentSite.HomePage = _routableHomePageProvider.GetSettingValue(part.ContentItem.Id);

View File

@@ -33,7 +33,7 @@ namespace Orchard.Core.Routable.Handlers {
OnGetEditorShape<RoutePart>(SetModelProperties);
OnUpdateEditorShape<RoutePart>(SetModelProperties);
OnPublished<RoutePart>((context, routable) => {
OnPublishing<RoutePart>((context, routable) => {
if (context.PublishingItemVersionRecord != null)
processSlug(routable);
if (!string.IsNullOrEmpty(routable.Path))