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.
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 [...]
Epi Server 7
var pageId = 1;
var pageRef = new PageReference(pageId);
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var page = contentRepository.Get<PageDa[...]
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.
var startpage = DataFactory.Instance.Get<PageData>(ContentReference.StartPage);
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
var pageRouteHelper = EPiServer.ServiceLocation.ServiceLocator.Current.Ge[...]
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'[...]
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 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 pag[...]
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 wi[...]
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 dyn[...]
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 powerfu[...]
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 conte[...]
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.
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 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 expl[...]
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.
If you need to write an initialization module or you're writing some code to automate your continuous integration process, it's very likely you may need to get the file path where your App_data folder lives on your server. Luckily, this is pretty ea[...]