diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs
index c0661ac272..779b4e4dea 100644
--- a/src/Umbraco.Core/Services/ContentService.cs
+++ b/src/Umbraco.Core/Services/ContentService.cs
@@ -221,6 +221,19 @@ namespace Umbraco.Core.Services
}
}
+ ///
+ /// Gets an object by Id
+ ///
+ /// Ids of the Content to retrieve
+ ///
+ internal IEnumerable GetByIds(IEnumerable ids)
+ {
+ using (var repository = _repositoryFactory.CreateContentRepository(_uowProvider.GetUnitOfWork()))
+ {
+ return repository.GetAll(ids.ToArray());
+ }
+ }
+
///
/// Gets an object by its 'UniqueId'
///
diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js
index e7de992f94..862b55d8a2 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js
@@ -10,6 +10,14 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
return Umbraco.Sys.ServerVariables.contentApiBaseUrl + "GetById?id=" + contentId;
}
/** internal method to get the api url */
+ function getByIdsUrl(ids) {
+ var idQuery = "";
+ _.each(ids, function(item) {
+ idQuery += "ids=" + item + "&";
+ });
+ return Umbraco.Sys.ServerVariables.contentApiBaseUrl + "GetById?" + idQuery;
+ }
+ /** internal method to get the api url */
function getEmptyContentUrl(contentTypeAlias, parentId) {
return Umbraco.Sys.ServerVariables.contentApiBaseUrl + "GetEmpty?contentTypeAlias=" + contentTypeAlias + "&parentId=" + parentId;
}
@@ -46,6 +54,22 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
return deferred.promise;
},
+
+ getByIds: function (ids) {
+
+ var deferred = $q.defer();
+
+ //go and get the data
+ $http.get(getByIdsUrl(ids)).
+ success(function (data, status, headers, config) {
+ deferred.resolve(data);
+ }).
+ error(function (data, status, headers, config) {
+ deferred.reject('Failed to retreive data for content ids ' + ids);
+ });
+
+ return deferred.promise;
+ },
/** returns an empty content object which can be persistent on the content service
requires the parent id and the alias of the content type to base the scaffold on */
diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs
index 5eebc7cc75..1beb8c20de 100644
--- a/src/Umbraco.Web/Editors/ContentController.cs
+++ b/src/Umbraco.Web/Editors/ContentController.cs
@@ -7,6 +7,7 @@ using System.Web.Http.ModelBinding;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Editors;
+using Umbraco.Core.Services;
using Umbraco.Web.Models.ContentEditing;
using Umbraco.Web.Models.Mapping;
using Umbraco.Web.Mvc;
@@ -54,6 +55,13 @@ namespace Umbraco.Web.Editors
controllerContext.Configuration.Formatters.Remove(controllerContext.Configuration.Formatters.XmlFormatter);
}
+ public IEnumerable GetByIds([FromUri]int[] ids)
+ {
+ var foundContent = ((ContentService) Services.ContentService).GetByIds(ids);
+
+ return foundContent.Select(x => _contentModelMapper.ToContentItemDisplay(x));
+ }
+
///
/// Gets the content json for the content id
///