Site Logo
How to get girlfriend or boyfriend > Looking for a girlfriend > Episerver get friendly url from contentreference

Episerver get friendly url from contentreference

Site Logo

I'm having a problem when trying to render an Url from an Url property in my view. Problem is that I want the friendly URL either it's an internal nor an external link. PageUrl Model. ToString but for the internal link this only gives me the ID to the page. How to get this done for both internal and external links?

Content:
SEE VIDEO BY TOPIC: SEO Manager - Create Friendly URL

Resolving page URL

Site Logo

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.

PageUrl helper. This helper only takes one parameter: the internal URL for the page. You could then take that string and use it directly in an HTML anchor tag.

This covers a lot of the other cases when you need better flexibility when creating a link to a page. It only returns the friendly URL to a page like Url. PageLink supports. I also made it support additional route data information, which will help when creating links to pages in another language branch.

I hope you find this useful, and that it gives you the most flexibility you need when creating a link to a page in your EPiServer site! PageLink Model. SomePageReference Html.

SomePageData Html. PageLink "A link to a page", Model. PageLink "A link to a Swedish page", Model. PageLink "A link with a class", Model. PageUrl Model. HasTemplate page return string. Empty; switch page. Normal: case PageShortcutType. Shortcut: case PageShortcutType. FetchData: return UrlExtensions. PageUrl urlHelper, page. External: return page. Inactive: return string.

Empty; default: return string. IsNullOrEmpty pageLink return string. ContainsKey RoutingConstants. Name; if! Fallback values[RoutingConstants. LanguageKey] as string?? ToString ; UrlExtensions.

How to get the friendly URL of a page in EPiServer CMS

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.

Sometimes it seems as if the hardest thing in Episerver is to retreive a proper external url of a PageData or ContentReference item. This especially occurs on multi-language or multi-tenant sites. The url repository of Episerver may sometimes be complex, and the api's may be changing.

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. Missing translations should be displayed in English.

Extension methods for obtaining ContentReference from LinkItem and Url

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. AbsoluteUrlBySettings to make the Url can cause problems in production sites as depending on the config it may generate urls with the internal hosting url if using EPiServer hosting for example. Is gonna be back steadily in order to check out new posts. You are commenting using your WordPress. You are commenting using your Google account. You are commenting using your Twitter account.

Get external page urls on a multi-tenant multi-language Episerver site

Home About Us Contact Us. EpiServer - get absolute friendly url for given culture for page - episerver I've a following setup in my Manage Websites panel General Url is set to alloy. So for Search page I want to get absolute friendly url in all languages. I use following code to get friendly url for page found on Anders G.

In Episerver, we have a number of different ways of allowing content editors to add and set links on a website.

I am trying to get a friendly-url for a page of type ContentReference property in site settings in another page's controller. Debugging shows that neither the "urlResolver" nor the "SiteSettings. NewsletterSuccessPageRef" are null. Is there any way to create ShippingProvider programmatically?

Showing the friendly URL of a Content Reference or Url property in a PropertyList

GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. Skip to content. Permalink Dismiss Join GitHub today GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. Sign up.

By using our site, you acknowledge that you have read and understand our Cookie Policy , Privacy Policy , and our Terms of Service. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Using EpiServer 8. I've seen online posts that suggest the following:. UrlHelper' does not contain a definition for 'ContentUrl' and no extension method 'ContentUrl' accepting a first argument of type 'System. UrlHelper' could be found are you missing a using directive or an assembly reference?

Content URL, with or without shortcut?

The method is made up to be as simple as possible to illustrate the how unit testing against a ContentArea can be done, which turns out to be non-trivial. The idea is to make it easier to find the post when googling for the subject matter or problems you might have. For the record, this code has been tested with EPiServer 7. GetContent in the ContentAreaHelper. GetItemNames method. So how do we do that? So first we need a IContentRepository that returns our content when queried. This basically tells FakeItEasy that we need a IContentRepository instance that returns our content when queried for the given content reference.

Add(new ContentAreaItem {ContentLink = contentReference}); Get the Url to the EPiServer start page incl. language branch The easiest way is of course to just hard-code the page's address (we're using EPiServer's friendly Url function.

Home About Us Contact Us. EpiServer - get absolute friendly url for given culture for page - episerver I've a following setup in my Manage Websites panel General Url is set to alloy. So for Search page I want to get absolute friendly url in all languages. I use following code to get friendly url for page found on Anders G. ConvertToExternal builder, null, Encoding.

Customizing Episerver content delivery API.

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.

EPiServer Commerce – Redirect old URL to new URL job

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.

There is a bunch of articles how to get started with it in this mode.

.

Subscribe to RSS

.

Episerver Search & Navigation

.

Comments: 1
  1. Melkree

    I consider, that you are not right. Let's discuss it.

Thanks! Your comment will appear after verification.
Add a comment

© 2020 Online - Advisor on specific issues.