November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Views: | 15027 |
Number of votes: | 10 |
Average rating: |
Some time ago Joel Abrahamsson created PowerSlice for Episerver. A lot has happened with the Episerver platform since then, and now we are re-introducing PowerSlice to match the latest and greatest version Episerver. Expanding the page tree to locate a page can be time consuming on large websites with hierarchical navigation structures. PowerSlice provides a different way of listing and managing content, suitable for sites with large numbers of pages and blocks. PowerSlice is also useful for content that does not naturally fit into a hierarchical structure, for example news and articles on media sites, and blog postings.
A special thanks goes to Viktor Sahlström for code samples and the awesome demo video!
How does it work? PowerSlice lets developers divide website content into slices based on its properties. This is then used for creating customized super fast content filtering. PowerSlice is made available to editors as a gadget that can be added to the panes in CMS edit view.
The slices you see are filtered on the logged in user and content type. In the example below "slices" are applied for pages, blocks and articles, but more filters can be added. Content within a selected slice can be searched, as well as sorted based on name and publish date.
Content can be created directly from the PowerSlice gadget, and you can use the slices in the gadget to add for instance blocks to a page that you are creating.
Installing and using PowerSlice for Episerver CMS is easy, follow the steps below to get started.
Note: PowerSlice requires an Episerver Find license because EPiServer.Find is a dependency.
Ensure that you have the Episerver NuGet feed added as a package source in Visual Studio, and then install the PowerSlice package.
[ServiceConfiguration(typeof(IContentQuery)), ServiceConfiguration(typeof(IContentSlice))]
public class CategoriesSlice : ContentSliceBase<CategoryPage>
{
public override string Name
{
get { return "Categories"; }
}
public override int Order
{
get { return 5; }
}
public override bool HideSortOptions
{
get
{
return true;
}
}
}
public override IEnumerable<CreateOption> CreateOptions
{
get
{
var contentType = ContentTypeRepository.Load(typeof (TagPage));
var startpage = ContentLoader.Get<StartPage>(ContentReference.StartPage);
yield return new CreateOption(contentType.LocalizedName, startpage.TagsRoot, contentType.ID);
}
}
The type argument to the base class is just the first filter, you can add more.
protected override ITypeSearch<EditorialPageBase> Filter(
ITypeSearch<EditorialPageBase> searchRequest,
ContentQueryParameters parameters)
{
return searchRequest.Filter(x => x.Created.MatchYear(DateTime.Now.Year));
}
The examples below are used in the PowerSlice demo video [LINK]
[ServiceConfiguration(typeof(IContentQuery)), ServiceConfiguration(typeof(IContentSlice))]
public class MyPagesSlice : ContentSliceBase<SitePageData>
{
public override string Name
{
get { return "My Pages"; }
}
protected override ITypeSearch<SitePageData> Filter(ITypeSearch<SitePageData> searchRequest, ContentQueryParameters parameters)
{
var userName = HttpContext.Current.User.Identity.Name;
return searchRequest.Filter(x => x.MatchTypeHierarchy(typeof(IChangeTrackable)) & ((IChangeTrackable)x).CreatedBy.Match(userName));
}
}
[ServiceConfiguration(typeof(IContentQuery)), ServiceConfiguration(typeof(IContentSlice))]
public class BlocksSlice : ContentSliceBase<SiteBlockData>
{
public override string Name
{
get { return "Blocks"; }
}
}
[ServiceConfiguration(typeof(IContentQuery)), ServiceConfiguration(typeof(IContentSlice))]
public class ArticleSlice : ContentSliceBase<ArticlePage>
{
public override string Name
{
get { return "Articles"; }
}
public override IEnumerable<CreateOption> CreateOptions
{
get
{
var contentType = ContentTypeRepository.Load(typeof(ArticlePage));
yield return new CreateOption(contentType.LocalizedName, ContentReference.StartPage, contentType.ID);
}
}
}
[ServiceConfiguration(typeof(IContentQuery)), ServiceConfiguration(typeof(IContentSlice))]
public class PagesSlice : ContentSliceBase<StandardPage>
{
public override string Name
{
get { return "Pages"; }
}
}
Really nice!!!!
Great stuff.
Brilliant, indeed brilliant.
Currently working on a site with big tree where some nodes have lot of children. This could be great help. Thanx for sharing.
With the release of EPiServer CMS 9 we get a dependency to Find >10, whereas PowerSlice currently has a dependency to Find <10.>10.>
Any plans for upgradering the PowerSlice add-on to support version 10+ of Find?
I ran nuget command Install-Package PowerSlice on site with CMS version 9.6.1.0 and got below error:
Install-Package : Updating 'EPiServer.Framework 9.6.1' to 'EPiServer.Framework 8.0.0' failed. Unable to find a version of 'EPiServer.CMS.Core' that is compatible with 'EPiServer.Framework 8.0.0'.
At line:1 char:1
+ Install-Package PowerSlice
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Does this mean that Powerslice is supported below version 9 and above 7 or have i done something wrong, Please assist.
Would be nice if I could do batch actions. For example, I created a slice for listing the unused blocks. I would like to select all those and delete them. Is that possible to do?