Episerver API Explained

Getting content in and out of Episerver is one of the most frequent tasks you will do on every project.  This section I’ll cover APIs like the IContentRepository, used to get content from Episerver.  My guides cover the APIs you’ll need to use the most, Episerver also has full SDK documentation here which is worth reading.

MANGING PAGES

1. How do I get the “CurrentPage” from a controller ?
2. How To Get The Current Page In Episerver 8?
3. Getting a Page from an Id
4. Different Ways Of Casting Objects From The Episerver Api
5. How to get a reference to the start page or root page?
6. How To Get A List Of All Page Types Defined in Episerver

URL MANAGEMENT

1. How to get the page URL of a specific Episerver page?
2. Get friendly Url of a page in EPiServer
3. How To Check if an Episerver Page is Being Rendered in Edit Mode or Preview Mode

SEARCHING AND FILTERING

1. FindPagesWithCriteria: How to search for pages within Episerver

Latest Episerver API Tutorials

How To Get The Url For An Image In Episerver

When you create new sites, allowing content editors to add images to your site is kind of like building websites 101. Adding images in Episerver is, handily, equally as easy, and you can get up and running very quickly. Defining A Property The first thing you need to do is define an image property either […]

How To Get A List Of All Page Types Defined in Episerver

Episerver provides us developers with loads of useful and extendable APIs. In today's post, I'm going to quickly go over the IContentTypeRepository and how to write some code that will return all of the page types defined in your website. You can then use the IContentModelUsage to get a complete usage listing for a particular […]

How To Get The Current Page In Episerver 8?

In Episerver 8 we have two API's available for us to allow fetching and modifying content. These are the IContentLoader and the IContentRepository.  In today's guide, I'm going to cover how to do some basic API calls with Episerver and hopefully explain the difference between the two. This article is a follow on from How […]

Different Ways Of Casting Objects From The Episerver Api

I have talked previously about getting objects from the Episerver API here.  In today's guide, I'm going to cover the different ways you can retrieve your data back and some of the pro's and con's with each approach. The Cover All Scenario In Episerver all content has to inherit from the IContent interface.   IN order […]

How To Get A Page Types Id

There are a few times in Episerver when you need to know a page types Id.  In Episerver 6 you use the GetPageTypeID-method that return the Id. In Episerver 7 and upwards this has moved.  To access the code now you can use the IContentTypeRepository. In IContentTypeRepository you have useful features like Load<>, Save<>, Delete<> […]

How To Check if an Episerver Page is Being Rendered in Edit Mode or Preview Mode

There are a number of situations where you may need to display information differently; when a page is being rendered in the editor, or, previewed. you may want to display different classes, or, even hide or show whole sections of code to allow content editors to have access to some additional back-end only features.  In Episerver […]

FindPagesWithCriteria: How to search for pages within Episerver

A common requirement in projects is to search for pages within Episerver.  One obvious example is for your websites search (When it comes to site searching you have many options like Google Site Search or EpiFind) EPiServer provides a pretty powerful and flexible search API out of the box, FindPagesWithCriteria. In EpiWorld you can build […]

How to generate a Episerver Page Url for a specific language

When you work with the LinkURL property in the PageData object in EPiServer, the Url will always be set to the current language. If you are working with a multi-language website, however, sometimes you need to create links to different languages dynamically. In order to generate a link to a specific language, you can use […]

Get friendly Url of a page in EPiServer

There are several ways of getting a Url for a page.  If you want to get a friendly Url from a view, then I would strongly recommend reading this post to see all the options available to you: Creating a friendly URL within your EPiServer 7 MVC View with Route Data. If, however, you want […]

How to get the page URL of a specific Episerver page?

Generating links and anchor tags to other areas within your website is a very common requirement in a project, and luckily, the EPi API makes it very easy to do.  There are several ways to ge the current page Url, so here goes: To get the current pages Url To get the Url for the […]

How to get a reference to the start page or root page?

Getting a page or content reference to some of the basic Episerver functionality is extremely easy and is given to you out of the box.  Below shows you how to get a reference to the start page, root page and the block folder.

Generating a friendly URL within your EPiServer MVC View

SEO friendly URLs are essential to improve the usability and accessibility of your website, also by hiding your Page Id's from your customer, you're adding an extra layer of security by not leaking any of your internal Episerver data.  A page ID isn't the worst thing in the world to pass as a querystring parameter […]

EPiServer 7 : How do I get the "CurrentPage" from a controller ?

I've had a few instances where I've needed to get the current page in a block controller or from an ActionFilter, so I thought I'd add a link to say: Getting A Page Reference Getting The Page Object

How to get a page in EPiServer 7 ?

 How To Get An EPiServer Page Via the API In EPi7 you can still use the traditional call to the API, however, this way isn't classed as best practice anymore. In EPi 7 the best practice approach is: If you are asking yourself why the second snippet is better, I'll explain. In the original version 6 API a […]

EPiServer : Getting a Page from an Id

Epi Server 7 or The different between the above two snippets of code is the interface passed into GetInstance. IContentloader was designed for read only tasks and has a much simpler interface definition.  In this case, IContentLoader is the simpler way. If you need to modify and save the page after the Get then you […]

EPiServer : How To Get Unpublished Child Pages With Meta Data

I've recently taken over a project that was developed by a third party company.  The site uses a number of hub/stack pages to pull in child pages to make up the page content to automatically create page placeholders from a side nav.  We had an issue where content editors could not fully preview a stack […]