In this tutorial, you will learn about 'projects'. An Episerver 'project' can be thought of as a giant bucket where a content editor can make a batch of content changes. Projects are useful for creating marketing campaigns. A content editor can group all content changes related to a marketing campaign into a single project. The project can be amended and tweaked until the editor is happy. The entirety of the project can then be scheduled to publish at a certain point in time. When that time is reached the whole campaign will go live in one fell swoop.
Before projects, it was not possible for content editors to work on and preview a whole campaign this way. They were forced into previewing upcoming changes one page at a time. This is why 'projects' was such a game-changer for content editors!
As we are developers, you might be wondering how you work with projects in code. Like everything else Episerver based, projects can be accessed via an API, the ProjectRepository API. For the curious,
ProjectRepository can be found within
Episerver.Core assembly. Strangely for an Episerver class,
ProjectRepository does not implement any type of interface. You can still use dependency injection to access
ProjectRepository, just note you will be working with a concrete implementation, rather than an interface. The
ProjectRepository exposes a number of useful functionalities:
To get a list of all the projects that have been created within your website using only the power of code, you can use this snippet:
To get access to a specific project, you can use this snippet:
To get a list of all active projects, you can filter projects like this:
To create and update a project you can use the
Save() works on a per-project basis and can be used like this:
You can also save individual content items within the project, using
SaveItems() like this:
There are two ways to delete a project via code. On a per-project basis, or, in a batch. To delete a batch of projects at the same time, you use
To delete a project on a per-project basis is done using
DeleteItem(), like this:
That is all there is to it. As you can see using the Episerver projects API is super-simple and self-explanatory. When dealing with content changes across multiple pages I recommend that you make use of projects as it will make your life easier. Happy Coding!