Episerver get friendly url from url property
SEE VIDEO BY TOPIC: Make SEO Friendly or Clean Url in PHP using .htaccessContent:
EPiServer 7 and MVC – Getting the URL for a page
It manages content. Having predictable methods for creating, modifying and retrieving content is crucial for a CMS. Most of the content can probably be accessed using some sort of URL.
So given I have some sort of content, in this example a PageData object. PageData is the base of all pages in an Episerver site. We could try the LinkURL property. It provides some sort of URL. It's not a friendly URL. It's not friendly for our website's visitors and it's not friendly to search engines. But it works. Suppose we move to a Razor view, and our model contains a reference to a PageData object, a ContentReference.
We would like to present a clickable html link, that points to our PageData. Say I would like full control over my anchor tag. Maybe add another link text, some custom attributes or just some marquee. So, times move on, and I create a new page, and I want my old page to send visitors to my new page.
So two methods ContentUrl and ContentLink. The first gives me only the Url and the latter gives me markup for the full Link. This is as expected. But why does one respect shortcut settings, while the other does not? Can Episerver help me with that? PageUrl , that will respect the shortcut settings. Being consistent is good. Giving different URLs to the same content in different scenarios, without good reason, is confusing.
If you create a link to the old content, and a user clicks that link, the user will be redirected to the new content. It will still work, but one less redirect is better. I can implement my own UrlExtension as Episerver has done in the Alloy demo site. Just lines of code, including this:. I would prefer not having to maintain my own UrlExtension-class to perform a task that should be key to any Content Management System. I luckily managed to convince Episerver Support and the dev team that this kind of functionality should be part of Episerver core.
Maybe I get it for christmas? Published: 17 Oct episerver.
Showing the friendly URL of a Content Reference or Url property in a PropertyList
There is a bunch of articles how to get started with it in this mode. Default Alloy template allows you to quickly get content API up and running, but the default output result is far from being perfect for real case usage and usually requires customization. Cms dependency to default Alloy site. With the default configuration you get predefined API endpoints and extensive output models.
In one of our project I had to refactor a code responsible for generating XML feed. The feed contains information like title, description and URL. There are three languages enabled for the site: English, Swedish and Norwegian. All pages was first created in English and some page translations are missing for Norwegian and Swedish.
Episerver blog by Ted & Gustaf
It manages content. Having predictable methods for creating, modifying and retrieving content is crucial for a CMS. Most of the content can probably be accessed using some sort of URL. So given I have some sort of content, in this example a PageData object. PageData is the base of all pages in an Episerver site. We could try the LinkURL property. It provides some sort of URL. It's not a friendly URL. It's not friendly for our website's visitors and it's not friendly to search engines. But it works.
Customizing Episerver content delivery API.
With EPiServer 7 that changes. This method resides in a class in the EPiServer. Html namespace and has a single parameter of type string named classicalUrl. In a view it may look like this:.
GetUrl with just a ContentReference as a parameter will return a url in the same context as the current request that is it the current request in onpageedit then the url will be in onpageedit format. This website is mostly a walkby for all the info you wished about this and didnt know who to ask. Glimpse right here, and also youll undoubtedly uncover it. Using UriSupport.
How to get the friendly URL of a page in EPiServer CMS
Page 1 2 Maybe there are other posts about this, but I thought I'd share an easy way of getting the friendly URL of a page since I've gotten questions about it on numerous occasions:. So, you should probably not ignore the PageLink parameter unless you have to - URL rewriting is probably the most expensive operation carried out by EPiServer.
Instead, rely on the helpers and extensions that EPiServer 7 provides. PageLink helper. For the text of the link, if you do not supply it with a text string, it will use the PageName property for the page or the Text property for a LinkItem object. You can also pass in route data information that can change the URL helpful when working with language branches or additional HTML attributes to add to the anchor tag. Be sure to check the SDK for this helper , because there are a lot more options you could use that might be a better fit for your needs. A common example is when you want to wrap an image tag with an anchor tag, or when you want to wrap more elements.
Resolving page URL
Ever wanted to introduce some special URL handling in your EPiServer web sites, like browsing pages per category by calling mysite. Well, rejoyce, cause now it's easier than ever before. NET framework 3. Originally built as a part of ASP. In fact, it works splendidly with Web Forms as well - or any other task you can think of. My personal guess is that we might do that eventually - but it's not as straightforward as it seems. First of all the UrlRouting only solves half the problem since we still need to rewrite all outputted html to friendly urls - and secondly, a number of implementations already have either hooked into the url rewriting or made their own based on the original.
When you work with EPiServer content data in MVC, the view does not have to take the content data object as view model. The received content data populates a view model that the view uses when a page loads. When a view uses a view model instead of the content data object, the edit view is unaware of connections between the properties on the view model and the properties on the content data object, which means that you cannot update parts of the page when you change content in the form edit view.
Subscribe to RSS
I was really trying to avoid blogging about any more custom properties, things related to PropertyList or Episerver editor UI customization. However, I felt like digging into how easy or hard it would be to show friendly URLs for ContentReference and Url properties in a PropertyList, so I thought I may as well revisit all of the areas I was trying to avoid in one blog post! I should also preface this post by saying that the code here is essentially a code experiment and I'm sharing it with that proviso. Finally, it's worth noting that Episerver don't actually support using the Url property in a PropertyList see this forum answer so it's probably worth keeping that in mind.
In Episerver, we have a number of different ways of allowing content editors to add and set links on a website. In today's guide, I'm going to cover how to add an Episerver. Url property to a page-type or block, and then how to render that Url on your website so it uses the friendly Url and not the ugly internal Episerver identifier.