2017-10-11 54 views
1

我使用Umbraco 7.7製作一個站點,並且我有一個如下所示的內容樹。更改Umbraco中活動語言的URL 7

Content Tree

使用Vorto新聞(圖像呼號)爲所有語言版本作出(目前只有荷蘭語版本)

問題是新聞頁面的網址。現在,它看起來像這樣:

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的最後一部分,它不可能爲其他語言的同一頁創建多個網址。

這是結果。我已經輸入本文nl/nieuws和URL被改變本作的新聞頁面:

http://localhost/data/nlnieuws 

我也嘗試了Vorto編輯器爲多國語言,但我有這個網址:

http://localhost:51086/data/values-nl-benlnieuws-dtdguid36eceba8-82ce-4362-954b-a870c65adfc1/ 

我應該如何改變依賴於actieve語言的URL

回答

2

您需要,如果你想個創建自定義UrlProviderContentFinder在。

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(); 
    } 
} 

實現並不複雜,但也不是那麼容易,對於這個答案來說太長了。

爲了給你一個想法如何去做檢查這個博客帖子:

https://24days.in/umbraco-cms/2014/urlprovider-and-contentfinder/

+0

發現了一把umbraco論壇更簡單的答案。檢查這個鏈接:https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/88635-change-url-dependent-of-the-active-language-in-umbraco-7#評論-280214但謝謝你的幫助:) –

0

發現了一把umbraco論壇更簡單的答案。

隨着Vorto,或其他任何東西真的,如果你想在語言/文化的URL蛞蝓只是父節點→點擊上單擊鼠標右鍵文化和主機名 →域中欄填入您選擇語言→ //mydomain.com/nl//mydomain.com/en/

超級簡單。它會將其添加到您選擇的節點下的每個頁面。

來源:our.umbraco.org forum (Change URL dependent of the active language in Umbraco 7)