PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 12/19/2018 3:23 PM by  Will Strohl
Hotcakes Top 10 Products
 7 Replies
 1 Subscribed to this topic
 1 Subscribed to this forum
Sort:
You are not authorized to post a reply.
Page 1 of 212 > >>
Author Messages





New Member






--
9/11/2017 9:31 AM
    hi
    i wanna custom this module . i wanna to show product image with name , could you please help me how i can do.





    Veteran Member






    --
    9/22/2017 10:03 PM
    Hello:

    The default template for this view looks something like this:

     

    The product name already appears to be there. It sounds like you want to show an image along with the name. Here's a snippet replacement that can help you get there. It's untested, but it should get you where you need to be. Note the additional method, and the image added to the HTML.

    [CODE]@model Hotcakes.Modules.Core.Models.SideMenuViewModel @functions{ string GetProductImage(string url) { // get an instance of the Hotcakes application var hccApp = Hotcakes.Commerce.HotcakesApplication.Current; // create a cache key var current = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings(); var cacheKey = string.Concat("HccTop10", current.ActiveTab); // see if the products are already cached var cachedItems = DotNetNuke.Services.Cache.CachingProvider.Instance().GetItem(cacheKey); if (cachedItems == null) { // load the products from a query only if a cached collection doesn't already exist var s = new DateTime(1900, 1, 1); var e = new DateTime(3000, 12, 31); cachedItems = hccApp.ReportingTopSellersByDate(s, e, 10); // cache the products to prevent performance issues DotNetNuke.Services.Cache.CachingProvider.Instance().Insert(cacheKey, cachedItems); } // convet the cached products to a usable list var products = (List) cachedItems; // iterate through each of the 10 products in the collection foreach (var product in products) { if (Hotcakes.Commerce.Utilities.UrlRewriter.BuildUrlForProduct(product) == url) { // return the product image only if the URL's match return product.ImageFileMedium; } } // return a generic image, in the event that there isn't a matching product image/URL return "/Portals/0/some-folder/generic-image.png"; } } <div class="hc-top-10-products"> <h2>@Model.Title</h2> <ol> @foreach (var item in Model.Items) { <li><a href="@item.Url" title="@item.Title"> <img src="@GetProductImage(item.Url)" alt=""/><br />@item.Name </a></li> } </ol> </div>
    Will Strohl, Upendo Ventures Hotcakes Cloud | Get Support | Code Support Official Cloud & Support provider for Hotcakes





    New Member






    --
    9/27/2017 11:36 AM
    hi dear
    thancks so much for reply
    i used these codes but images doesnt show yet.please see this this site :
    http://mytest.com.iis2001.shared-servers.com/





    Veteran Member






    --
    9/30/2017 2:01 PM
    It actually looks like it is working, but the image path isn't complete. It's only the image file name, and it doesn't include the rest of the image path. (Like I said, it was untested.)

    Look for this line of code in the example:

    [code=csharp]return product.ImageFileMedium;[/code]

    Try replacing it with this:

    [code=csharp]
    return DiskStorage.ProductImageUrlSmall(
    hccApp,
    product.Bvin,
    product.ImageFileSmall,
    hccApp.IsCurrentRequestSecure());
    [/code]

    Or this:

    [code=csharp]
    return DiskStorage.ProductImageUrlOriginal(
    hccApp,
    product.Bvin,
    product.ImageFileSmall,
    hccApp.CurrentRequestContext.RoutingContext.HttpContext.Request.IsSecureConnection);[/code]

    You'll probably also need to import one or both of the following namespaces:

    [code=csharp]
    @using Hotcakes.Commerce.Storage
    @using Hotcakes.Commerce.Utilities
    [/code]

    By the way, this kind of inquiry is covered, with guaranteed response times under our Developer Support Services.

    https://upendoventures.co...ce-Developer-Support
    Will Strohl, Upendo Ventures Hotcakes Cloud | Get Support | Code Support Official Cloud & Support provider for Hotcakes





    New Member






    --
    10/3/2017 9:52 AM
    thanks so much , now its ok.
    You are not authorized to post a reply.
    Page 1 of 212 > >>


    Loading
    • Sign-up for the Hotcakes Community Newsletter: