+1-888-365-2779
Try Now
More in this section

Forums / Project Feather / Product title in breadcrumb

Product title in breadcrumb

2 posts, 0 answered
  1. Stacey
    Stacey avatar
    291 posts
    Registered:
    18 Oct 2012
    04 May
    Link to this post

    I am trying to get product titles to show up in the feather breadcrumb widget following the information in the following two links:

    http://www.sitefinity.com/blogs/slavo-ingilizovs-blog/2013/01/24/including-item-titles-in-the-sitefinity-breadcrumb
    http://docs.sitefinity.com/tutorial-set-virtual-nodes-in-the-breadcrumb-widget

    This is for Sitefinity 8.2 / Feather 1.4.450.0

    I have a custom mvc widget that displays master/details for Sitefinity e-commerce products.  These widgets are being used on hybrid pages and I have verified through debugging and successfully adding the canonical url that the page reference is not null.  What else do I need to add into this to register virtual nodes?

    The breadcrumb widget has its AllowVirtualNodes property set to true.

     

    Below is the code I have in my custom product controller.

    public ActionResult Index()
           {
               ViewBag.CurrentPageUrl = this.GetCurrentPageUrl();
     
               return View("Default");
           }
     
           public ActionResult Details(Product productItem)
           {
               var viewModel = service.CreateProductDetailsViewModel(productItem);
               var page = this.HttpContext.CurrentHandler.GetPageHandler();
     
               this.ProductTitle = productItem.Title;
               this.AddCanonicalUrlTagIfEnabled(page, productItem);
               page.RegisterBreadcrumbExtender(this);
     
               return View(viewModel);
           }
     
    public IEnumerable<SiteMapNode> GetVirtualNodes(SiteMapProvider provider)
           {
               return new List<SiteMapNode>() { new SiteMapNode(provider, "customBreadcrumbKey", "~/url", this.ProductTitle) };
           }

  2. Stacey
    Stacey avatar
    291 posts
    Registered:
    18 Oct 2012
    05 May
    Link to this post

    Through some help on Google+ (thanks Vesselin) It turns out the issue is that my breadbrumb initializes before the custom controller.  What I have done is to create a new widget to be dropped above the breadcrumb.

     

    Here is a working example:

    [ControllerToolboxItem(Name = "ProductBreadcrumbExtender", Title = "Product Breadcrumb Extender", SectionName = "MvcWidgets")]
    public class ProductBreadcrumbController : Controller, IBreadcrumExtender
    {
        #region Properties
     
        public string ProductTitle { get; set; }
     
        #endregion
     
        #region Actions
     
        public void Details(Product productItem)
        {
            this.ProductTitle = productItem.Title;
            var page = this.HttpContext.CurrentHandler.GetPageHandler();
            page.RegisterBreadcrumbExtender(this);
        }
     
        public IEnumerable<SiteMapNode> GetVirtualNodes(SiteMapProvider provider)
        {
            return new List<System.Web.SiteMapNode>() { new System.Web.SiteMapNode(provider, "customBreadcrumbKey", "~/url", this.ProductTitle) };
        }
     
        #endregion
    }

     

2 posts, 0 answered