ありがとうございます。私は自分の作業設定を共有します
//Ưu tiên Search
routes.MapRoute(name: "search", url: "{lang}/search/{keyword}", defaults: new { controller = "search", action = "result" });
//Normal with Language
routes.MapRoute(
name: "Language",
url: "{lang}",
defaults: new { controller = "Home", action = "Index", lang = UrlParameter.Optional },
constraints: new { lang = @"(\w{2})" }
);
//News Category
routes.MapRoute(
name: "defaultLanguageWithCate",
url: "{cateSlug}",
defaults: new { lang = "vi", controller = "News", action = "NewsByCate" },
constraints: new { lang = @"(\w{2})", controller = "News", action = "NewsByCate" },
namespaces: new[] { "Frontend.Web.Controllers" }
);
routes.MapRoute(
name: "languageWithCate",
url: "{lang}/{cateSlug}",
defaults: new { lang = "vi", controller = "News", action = "NewsByCate" },
constraints: new { lang = @"(\w{2})", controller = "News", action = "NewsByCate" },
namespaces: new[] { "Frontend.Web.Controllers" }
);
//News Detail
routes.MapRoute(
name: "defaultLanguageWithArticle",
url: "{cateSlug}/{articleSlug}",
defaults: new { lang = "vi", controller = "News", action = "Detail" },
constraints: new { lang = @"(\w{2})", controller = "News", action = "Detail" },
namespaces: new[] { "Frontend.Web.Controllers" }
);
routes.MapRoute(
name: "languageWithArticle",
url: "{lang}/{cateSlug}/{articleSlug}",
defaults: new { lang = "vi", controller = "News", action = "Detail" },
constraints: new { lang = @"(\w{2})", controller = "News", action = "Detail" },
namespaces: new[] { "Frontend.Web.Controllers" }
);
//Không có Language
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, lang = "vi" }
);
それぞれに関連付けられたコントローラメソッドとはどのようなものですか?たとえば5番の場合は '../ fr/News/Detail/10'(あるいは単に' ..fr/Details/10')に 'ID = 10'のニュース項目の詳細を表示しますかフランス語で? –
この質問は、Drupalに慣れていない人にとってはむしろあいまいですが、[この回答](http://stackoverflow.com/a/32839796/181087)は正しい方向にあなたを導きます。 – NightOwl888
{root}/{catePermanentLink}/{newsPermanentLink} ==>ニュースの詳細を既定の言語で表示します。 {root}/fr/{catePermanentLink}/{newsPermanentLink} ==> FR言語によるニュースの詳細 – Linc