-
Notifications
You must be signed in to change notification settings - Fork 82
3. Pages
Haytam Zanid edited this page Apr 17, 2019
·
2 revisions
Whenever you have a page that you want to include in your breadcrumbs, you'll have to annotate it with the Breadcrumb attribute.
If your page is a child of the default page, all you need to do is specify the tilte:
Razor Page
[Breadcrumb("About Me")]
public class AboutModel : PageModel
{
...
}MVC Action
[Breadcrumb("About Me")]
public IActionResult About()
{
...
}If your page is a child of a Razor Page, you'll have to specify it in the FromPage property:
Razor Page
[Breadcrumb("Contact Me", FromPage = typeof(AboutModel))]
public class ContactModel : PageModel
{
...
}MVC Action
[Breadcrumb("Contact Me", FromPage = typeof(AboutModel))]
public IActionResult Contact()
{
...
}If your page is a child of an MVC page, you'll have to specify it in the FromAction and FromController properties:
Razor Page
[Breadcrumb("Contact Me", FromAction = "Contact", FromController = typeof(HomeController))]
public class ContactModel : PageModel
{
...
}MVC Action
[Breadcrumb("Contact Me", FromAction = "Contact", FromController = typeof(HomeController))]
public IActionResult Contact()
{
...
}If the FromPage is in the same Controller as the action you're annotating, you can avoid specifying the FromController property, as SmartBreadcrumbs can infer it from the class type:
public class HomeController()
{
[DefaultBreadcrumb("My Home Page")]
public IActionResult Index()
{
return View();
}
[DefaultBreadcrumb("About Me")]
public IActionResult About()
{
return View();
}
// Here, the HomeController will be used as the FromController
[DefaultBreadcrumb("Contact Me", FromAction = "About")]
public IActionResult Contact()
{
return View();
}
}