Hello,
On the main menu of my website , I have a page that has sub menus.
I want to point the sub menu tab to an external URL. I used the below link to change the URL of the sub menu page but it does not work :
There are different ways to solve this, but what I tend is creating implementing af custom IUrlProvider:
public class ExternalUrlProvider : IUrlProvider
{
public IEnumerable<UrlInfo> GetOtherUrls(UmbracoContext umbracoContext, int id, Uri current)
{
return Enumerable.Empty<UrlInfo>();
}
public UrlInfo GetUrl(UmbracoContext umbracoContext, IPublishedContent content, UrlMode mode, string culture, Uri current)
{
if (content is ContentModels.ExternalPage page)
{
var externalUrl = page.ExternalUrl;
if (string.IsNullOrWhiteSpace(externalUrl)) return null;
return new UrlInfo(externalUrl, true, culture);
}
return null;
}
}
}
In this case I have a custom External Page (externalPage) document type and the ExternalPage class is generated by ModelsBuilder.
Furthermore I have an extension method:
public static class PublishedContentExtensions
{
public static bool IsExternal(this IPublishedContent content)
{
return content is ContentModels.ExternalPage;
}
}
so in navigation you can do something specific with this page type:
Hi Bjarne,
Thank you for the solution but is there any other way I can do this? I mean directly from the front end ? In the "Properties" section, I found an Alternative URL section. It is using the UmbracoURlAlias . I tried entering my external link there but that did not help either :
Is there something I can do directly from the front end side ?
Point sub-menu page to external URL
Hello, On the main menu of my website , I have a page that has sub menus. I want to point the sub menu tab to an external URL. I used the below link to change the URL of the sub menu page but it does not work :
https://our.umbraco.com/Documentation/Reference/Routing/routing-properties
The link does help me to change the URL of my page but it does not let my sub menu page point to an external URL
Below picture shows what I am trying to do :
I am trying to point the sub-menu page "Power Engineer/Inspector Login" to an external link i.e. https://apecsonline.absa.ca/Account/Login
Can this be done on umbraco version 7.12.1 ?
Hi Qamar
There are different ways to solve this, but what I tend is creating implementing af custom
IUrlProvider
:In this case I have a custom
External Page
(externalPage) document type and theExternalPage
class is generated by ModelsBuilder.Furthermore I have an extension method:
so in navigation you can do something specific with this page type:
There are some documentation here regarding
IUrlProvider
: https://our.umbraco.com/Documentation/Reference/Routing/Request-Pipeline/outbound-pipeline-vpre81 but should also be available in v7: https://24days.in/umbraco-cms/2014/urlprovider-and-contentfinderHi Bjarne, Thank you for the solution but is there any other way I can do this? I mean directly from the front end ? In the "Properties" section, I found an Alternative URL section. It is using the UmbracoURlAlias . I tried entering my external link there but that did not help either :
Is there something I can do directly from the front end side ?
Were you able to figured this out? I'm currently stuck on this too
is working on a reply...