and I'm trying to remove Convenience and Pharmacy from the url structure.
I've created a custom URL provider:
public class CustomUrlProvider : DefaultUrlProvider
{
public override string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
{
var home = new UmbracoHelper(UmbracoContext.Current).TypedContentAtRoot().First(x => x.DocumentTypeAlias.Equals("HomePage"));
var categories = home.Children.Where(x => x.DocumentTypeAlias.Equals("CategoryPage"));
{
public bool TryFindContent(PublishedContentRequest contentRequest)
{
if (contentRequest != null)
{
// copy ContentFinderByNiceUrl but add your prefix back where it's missing
const string PREFIX = "/convenience";
The problem is, the URLprovider gets itself in a constant loop when comparing the category.Url with the current node Url, and the ContentFinder is using magic strings instead of looking up the CategoryPage.
Is there a better way of doing it, should I be looking at a Custom Segment provider instead?
Remove segment from URL
I have this structure on my site:
and I'm trying to remove Convenience and Pharmacy from the url structure.
I've created a custom URL provider:
{ public override string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode) { var home = new UmbracoHelper(UmbracoContext.Current).TypedContentAtRoot().First(x => x.DocumentTypeAlias.Equals("HomePage")); var categories = home.Children.Where(x => x.DocumentTypeAlias.Equals("CategoryPage"));
} }
and a custom ContentFinder:
{ public bool TryFindContent(PublishedContentRequest contentRequest) { if (contentRequest != null) { // copy ContentFinderByNiceUrl but add your prefix back where it's missing const string PREFIX = "/convenience";
}
The problem is, the URLprovider gets itself in a constant loop when comparing the category.Url with the current node Url, and the ContentFinder is using magic strings instead of looking up the CategoryPage.
Is there a better way of doing it, should I be looking at a Custom Segment provider instead?
If you are trying to hide it from a dynamic navigation, you can do it by checking it "hide from navigation". This is in the following path:
Content:
That should hide it from the navigation bar but if i have miss understood the question, please respond and i'll try to help where i can.
Hi ianhoughton,
Perhaps this post from the Umbraco advent calendar from 2014 can help you to archive what you are trying to, regarding to modify the URL
http://24days.in/umbraco/2014/urlprovider-and-contentfinder/
As you can see Jeroen is also talks about the Hybrid framework which you can find here. https://our.umbraco.org/projects/developer-tools/hybrid-framework-for-umbraco-v7/
Hope this helps,
/Dennis
Did you get this working?
It will and you will eventually crash your application pool because you have an infinite loop when using the .Url property. Instead try using
Hope that helps as I just got caught by the same issue.
However, overcoming this issue presented another problem as I've detailed here.
is working on a reply...