November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Can you try this?
var partialVirtualPath = string.Format("items/{0}", item.RouteSegment);
return new PartialRouteData
{
BasePathRoot = StartPageContentLink,
PartialVirtualPath = SegmentHelper.GetModifiedVirtualPathInEditOrPreviewMode(item.ContentLink, partialVirtualPath, requestContext.GetContextMode())
};
I tried that and I am getting the exact same result in the end. Once published and when I click on the link it redirects me to "mysite.com/?epsremainingpath=items%2FitemA%2F"
Thank you for the suggestion anyways :]
How do you insert the link into the editor? And do you render the property in a Razor view with Html.DisplayFor or Html.PropertyFor?
I visit the item I want and then copy the link directly from there, which in this case would be "http://mysite.com/items/item-A/" where "item-A" is the item SEO URL in the CMS.
And to render the field where I copy the link to
<div class="text-content" ng-bind-html="item.description | toTrustedHtml">
@Model.ItemDescription
</div>
May be worth mentioning that any other links that map to internal content (but that don't use a custom partial route) work fine using this same method.
Start with replacing @Model.ItemDescription
with @Html.DisplayFor(m => m.ItemDescription)
, and see if that makes any difference.
You should also use the link tool in TinyMCE editor to insert link to commerce item.
Replacing it with @Html.DisplayFor(m => m.ItemDescription) will make it render the link exactly as I paste it (without any mapping to the internal link) which is not the solution I am looking for. The data type of the description at the viewmodel scope is HtmlString..
When using the link tool in TinyMCE the link will be pointing to the content page in CMS which in return will make the user get an 401 and be redirected to the home page instead.
When you say catalog item, do you mean a commerce catalog item? If you use the link tool to select a catalog item and it ends up with a 401, then there must be some issue in your partial router.
I am sorry, after reading your reply I went back and did it again only to see that it didn't work because of a mistake a made.
In the meanwhile I have tried creating an Initialization module where I checked the methods CreatedVirtualPath, CreatingVirtualPath, RoutedContent and RoutingContent (from IContentRouteEvents) to make sure the args parameter content was actually correct... and it was, which left me thinking it was an Episerver problem. Although it doesn't look like anyone else has said anything similiar in these past days so it has to be something I did wrong on my part.
Even though the use of the create link feature on the TinyMCE is an option, for a content team that has to deal with a catalog with thousands of different items it saves a lot of their time by being able to paste the link from the url and letting Episerver do the internal mapping automatically... I am leaving that as a last resort.
Have you got any other ideas or suggestions?
I tested with a similar scenario (Commerce site with custom partial router for items) and had no problems pasting the URL in TinyMCE editor. When I open up the link tool for the pasted link, it has automatically been resolved as a "Catalog content" link type. But we are rendering the HTML with Html.PropertyFor and the data type on the model is XhtmlString.
Hi Mattias,
I have been working on different things since your last response and when I got back to this issue I decided to test a different implementation of the Partial Router.
Previously I was using a implementation that inherited the class HierarchicalCatalogPartialRouter and now I have replaced this with an implementation of the interface IPartialRouter (the differences between this two were really small) but with this change I was able to get my problem solved.
The last thing missing is to understand what was really happening here as I still have no idea. I tried reading both classes page on the Episerver documentation (for the version of Episerver I am using) but unfortunatly I had no luck there as they don't have that much relevant information for HierarchicalCatalogPartialRouter. Perhaps you have more insigh on this topic that you could share with me?
Thank you!
Hello,
I have a catalog item routed through a custom partial route as "mysite.com/items/itemA". Note that "mysite.com/items" doesn't represent any actual page on my website.
The problem appears when I paste the link "mysite.com/items/itemA" in any XHTML field on CMS. That link will be seen as internal and mapped to the corresponding internal link. I end up with something like "mysite.com/link/<string>.aspx?espremainingpath=items/itemA". Because "/items" does not correpond to any existing page, on GetPartialVirtualPath(), I return the BasePathRoot as the home page and include everything else in the PartialVirtualPath().
Unfortunatly when I click on the new generated link it will take me to the home page and will keep the espremainingpath as it is, so I would have something like "mysite.com/?epsremainingpath=items%2FitemA%2F" when the behavior I would be expecting would be for the espremainingpath to be interpreted.
As I can currenctly access any items when edting the url directly I assume that I didn't miss anything when implementing the custom partial route.
Is this an issue with Episerver or am I missing something? Thank you :]
The version of Episerver CMS I am using is 11.11.2 together with c# 7.3