Page 1 of 1

Category link in Wishlist page

Posted: Mon Jan 23, 2012 7:26 pm
by crockettdunn
I'm trying to link to a products parent category in the wishlist page, and I'm striking out. How can I expose the parent category id in this page?

thanks.

Re: Category link in Wishlist page

Posted: Mon Jan 23, 2012 7:41 pm
by crockettdunn
Maybe I should backup... the real objective is to make a "keep shopping" link that goes back to a category list view. I'm not clear how GetLastShoppingUrl is populated, so I decided to try to grab the category.

Re: Category link in Wishlist page

Posted: Tue Jan 24, 2012 8:40 am
by jmestep
The last shopping url is defined in the App_Code/NavigattionHelper.cs

Code: Select all

    /// <summary>
    /// Gets the last shopping url for the current user.
    /// </summary>
    /// <returns>The last shopping url for the current user.</returns>
    public static string GetLastShoppingUrl()
    {
        HttpContext context = HttpContext.Current;
        if (context == null) return "~/Default.aspx";
        Page page = context.Handler as Page;
        if (page == null) return "~/Default.aspx";
        PageViewCollection pageViews = Token.Instance.User.PageViews;
        pageViews.Sort("ActivityDate", GenericComparer.SortDirection.DESC);
        string homePage = page.ResolveUrl("~/Default.aspx");
        string searchPage = page.ResolveUrl("~/Search.aspx");
        string wishlistPage = page.ResolveUrl("~/ViewWishlist.aspx");
        foreach (PageView pageView in pageViews)
        {
            if ((pageView.UriStem == homePage) || (pageView.UriStem == searchPage) || (pageView.UriStem == wishlistPage)) return pageView.UriStem + "?" + pageView.UriQuery;
            if (pageView.CatalogNodeId != 0)
            {
                ICatalogable node = pageView.CatalogNode;
                if ((node != null) && ((pageView.CatalogNodeType == CatalogNodeType.Category) || (pageView.CatalogNodeType == CatalogNodeType.Product)))
                {
                    return node.NavigateUrl;
                }
            }
        }
        return homePage;
    }