根据Umbraco 7中的活动语言更改URL
我使用Umbraco 7.7创建了一个网站,我有一个如下所示的内容树 新闻(图片Nieuws)是针对使用Vorto的所有语言版本(目前只有荷兰语版本)制作的 问题是新闻页面的url。现在看起来是这样的:根据Umbraco 7中的活动语言更改URL,url,umbraco,umbraco7,Url,Umbraco,Umbraco7,我使用Umbraco 7.7创建了一个网站,我有一个如下所示的内容树 新闻(图片Nieuws)是针对使用Vorto的所有语言版本(目前只有荷兰语版本)制作的 问题是新闻页面的url。现在看起来是这样的: http://localhost/data/nieuws 我想将此更改为: http://localhost/nl/nieuws 或者如果我有其他语言: http://localhost/en/news 这也必须适用于新闻的子页面。例如: http://localhost/nl/nieu
http://localhost/data/nieuws
我想将此更改为:
http://localhost/nl/nieuws
或者如果我有其他语言:
http://localhost/en/news
这也必须适用于新闻的子页面。例如:
http://localhost/nl/nieuws/nieuwe-directeur
http://localhost/en/news/new-CEO
我尝试使用别名
umbracoUrlName
创建一个属性,但它只更改URL的最后一部分,不可能用其他语言为同一页面创建多个URL
结果如下。我已输入此文本nl/nieuws
,新闻页面的URL更改为:
http://localhost/data/nlnieuws
我还尝试使用Vorto编辑器来编辑多种语言,但我得到了以下url:
http://localhost:51086/data/values-nl-benlnieuws-dtdguid36eceba8-82ce-4362-954b-a870c65adfc1/
如何更改actieve语言的URL依赖项?如果需要,您需要创建自定义的
UrlProvider
和ContentFinder
public class DataUrlProvider : IUrlProvider
{
public virtual string GetUrl(UmbracoContext umbracoContext, int id, Uri current, UrlProviderMode mode)
{
throw new NotImplementedException();
}
public virtual IEnumerable<string> GetOtherUrls(UmbracoContext umbracoContext, int id, Uri current)
{
throw new NotImplementedException();
}
}
public class DataContentFinder : IContentFinder
{
public bool TryFindContent(PublishedContentRequest contentRequest)
{
throw new NotImplementedException();
}
}
公共类DataUrlProvider:IUrlProvider
{
公共虚拟字符串GetUrl(UmbracoContext UmbracoContext,int-id,Uri-current,UrlProviderMode模式)
{
抛出新的NotImplementedException();
}
公共虚拟IEnumerable GetOtherUrls(umbraContext umbraContext,int-id,Uri-current)
{
抛出新的NotImplementedException();
}
}
公共类DataContentFinder:IContentFinder
{
public bool TryFindContent(publishedContentRequestContentRequest)
{
抛出新的NotImplementedException();
}
}
实现并不是那么复杂,但也不是那么容易,而且对于这个答案来说太长了
要想让你知道如何做,请查看以下博客:
在翁布拉科论坛上找到了一个更简单的答案 对于Vorto,或者其他任何东西,如果您想要语言/文化的URL段塞,只需右键单击父节点→ 单击区域性和主机名→ 选择您的语言→ 在域字段中放入
//mydomain.com/nl/
/mydomain.com/en/
,等等
超级容易。它会将其添加到所选节点下的每个页面
资料来源:
在Umbraco论坛上找到了一个更简单的答案。查看此链接:但感谢您的帮助:)